I am attempting one of my js labs for college and have to create a function that generates a random number and then using that random number will change what the value of a variable and inturn us another function to change the source of an image file to what the variables value is …
I am using an if statement to change the source of the image, however , once i add the if else or else statements it comes back as unexpected token else , i have checked over this ten times and see no colons or semi colons out of place that would end the conditions . Can a fresh pair of eyes help me here as this is really bugging me!
<script>
var card1, card2, card3;
var x = Math.floor(Math.random()*3);
if (x == 1)
card1 = "queen.png"
card2 = "one.png"
card3 = "two.png"
else if (x ==2)
card1 = "one.png"
card2 = "two.png"
card3 = "queen.png"
else
card1="two.png"
card2="queen.png"
card3="one.png"
</script>