I'm currently learning javascript and I keep having this error!!!
This is my script:
var pare = 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";
}
I'm currently learning javascript and I keep having this error!!!
This is my script:
var pare = 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";
}
Share
Improve this question
edited Jun 18, 2015 at 16:27
lakshayg
2,1732 gold badges22 silver badges36 bronze badges
asked Jun 18, 2015 at 15:51
Brandon MagroBrandon Magro
331 gold badge1 silver badge3 bronze badges
1 Answer
Reset to default 2Should be:
var pare = 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";
}
Or neater:
var pare = 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"
}
}