What if choice1 is rock?


#1


Can anyone tell me where I'm going wrong?

https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/2?curriculum_id=506324b3a7dffd00020bf661#

SyntaxError: Unexpected end of input


  var compare = function(choice1,choice2) {
    if(choice1 === choice2) {
    return "The result is a tie!";
}
else if(choice1 === "rock") {
    if(choice2 === "scissors") {
        return "rock wins";
}
else {
    return "paper wins";
}
}


#2

just look this

else if(condition){
if(condition){
return somthing
}
}


#3

The error message gives a hint at the iissue... The function is not closed. Add one more closing brace to the bottom of the code.


#4

Thank-you. That did the trick. I always get so confused with braces, brackets, and semicolons and how to use them properly.


#5

Now you know one place to not use them. The same goes for any structure with a parameter list and a code block.

if () {} else if () {} else {}

while () {}

switch () {}

function () {}

for () {}

and never at the end, either. When a statement has = in it, it ends with a ;

var myFunction = function () {};

var myObject = {};

var a = "some value";

Statements that contain function call expressions get one...

myFunction();

console.log("something");

One while statement does get a semi-colon at the end, do..while:

do {} while ();

It will eventually get sorted out in time. Focus on concepts for now and the syntax side of it will come together.