Extra ideas "rock, paper, scissors"


#1


I'm playing with the ideas for "rock, paper, scissors".
I thought i could use a loop to check if userChoice is correct.
Is the peace of code I pasted correct?
If not where is the problem?

Many thanks,



SyntaxError: Illegal return statement


var possibleAnswer = ["rock", "paper", "scissors", "rope"];
for (var i = 0; i < possibleAnswer.length; i++) {
    if (possibleAnswer[i] === userChoice) {
        var correctUserChoice = userChoise;
    }
    else {
        return "You had to choose something else, naughty boy! ;-)";
    }
}


#2

return can only be used in functions, you don't have a function? Just use console.log() to let them know they made a wrong choice


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.