This forum is now read-only. Please use our new forums! Go to forums
banner
Close banner
Another unexpected else question..
Even after following one of the templates I found in FAQ I still get either else or { as an unexpected token (which to me are all completely expected!) since I can’t find any answer to why my code isn’t right I hope you guys can help..
var compare = function (choice1, choice2){
if (choice1 === choice2){
return "The result is a tie!";
}
else if(choice1 === "paper"){
if(choice2 === "rock"){
return "paper wins";
} // close if choice2 = rock
else(choice === "scissors"){
return "scissors wins";
} // close if choice2 = scissors
} // close else if choice 1 paper
}; // close function body
Thank you all in advance
Answer 55f457899113cb133400032a
0 votes
An ELSE statement does NOT take a condition…
Have a read through http://www.codecademy.com/forum_questions/559dcb4be39efe550f00006b and concentrate on the build of the IF ELSE-IF statement…
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency