Cant get rid of unexpected token else?

homework
javascript

#1

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>

#2

@megarunner02505,

-1 An IF statement construct will use a pair of curly-brackets-{ } to encapsulate a so-called code-block like
Please read the code-convention
http://javascript.crockford.com/code.html

if ( condition ) {
    //IF code-block
    //Multi-line of code
} else {
   //ELSE code-block
    //Multi-line of code
}

-2 a Math.floor(Math.random()*3); will return a number Value between 0 and 2

                                      Min   Max
Math.random()                          0 ... 0.9999
Math.random() * 3                      0 ... 0.2.9997
Math.floor( Math.random() * 3 )        0 ... 2
Math.floor( Math.random() * 3 + 1 )    1 ... 3

<script>

var card1, card2, card3;
var x = Math.floor(Math.random()*3)+1;

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>