8. What if choice1 is scissors help


#1

Hey guys, I keep getting Syntax error: unexpected token, I feel like my eyes are just drained from looking at this code so much, if anyone has fresh eyes can you check to see if I'm missing anything in my code?

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if(computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
} console.log("Computer: " + computerChoice);

var compare = function(choice1, choice2);
{
if (choic1 === choice2) {
return "It's a tie!";
}
else if (choice1 === "rock") {
if (choice2 === "paper") {
return "paper wins";
}
else {
return "rock wins";
}
else if (choice1 === "paper") {
if (choice2 === "rock") {
return "paper wins";
}
else {
return "scissor wins";
}
else if (choice1 === "scissors") {
if (choice2 === "rock") {
return "rock wins";
}
}
};
console.log(compare(userChoice,computerChoice));


#2

You shoud be getting a line number from the codecademy error message. Look in that general area.

Go through the braces and make sure they're all matched up too. If you place the cursor at a brace then the matching one should get slightly highlighted.

You will make mistakes the trick lies in being able to fix them.


#3

Firefox has a scratchpad where you can experiment with JS code, you would get better error messages there, it also has a pretty print functionality that indents your code based on your braces - making it easier to see where those are mismatched.

You can access it by pressing shift + F4 or Tools | Web Developer | Scratchpad


#4

Thank you! I will definitely try that out.


#5

Your advice worked! The scratchpad app pinpointed me to the correct lines and I was able to correct everything, thank you again!