I am trying to make a random image from an array appear onscreen with the page load. I know the page successfully gets a random img src, but the physical image never appears. Do I need to reference it in my html? How would I go about getting that random image src to make a visible image.
<!DOCTYPE html>
<html>
<head>
<title>Hiragana Flash Cards</title>
</head>
<body>
<h2>Hiragana Flash Cards</h2>
<script>
var imgArray = new Array();
imgArray[0] = new Image();
imgArray[0].src = 'a.png';
imgArray[1] = new Image();
imgArray[1].src = 'i.png';
imgArray[2] = new Image();
imgArray[2].src = 'u.png';
imgArray[3] = new Image();
imgArray[3].src = 'e.png';
imgArray[4] = new Image();
imgArray[4].src = 'o.png';
imgArray[5] = new Image();
imgArray[5].src = 'ka.png';
function imgRandom(imgArr) {
return imgArr[Math.floor(Math.random() * imgArr.length)];
}
console.log(imgRandom(imgArray));
</script>
</body>
</html>