my text editor does not like this piece of code I am not sure why
<script type="text/javascript">
function randmg(){
var img = [
"banner1.png",
"banner2.png",
"banner3.png",
"banner4.png"
]
var maxImg = img.length;
var randNum = Math.floor(Math.random()*maxImg)
return img[randNum]
}
</script>
It says the error is in line four “var img – [“
I thought that i was the use/placement of var under the array but I have not been able to fix it
Changed to this
function randmg(){
var img = ["banner1.png","banner2.png","banner3.png","banner4.png"];
var maxImg = img.length;
var randNum = Math.floor(Math.random()*maxImg);
return img[randNum];
}
But still having the same issue
yes, you need to add a semicolen at the end of that array.