Need code for all 3 ideas in 9)Next Steps of Build "rock,paper and scissors"


Can someone please post the code for all the three parts in Build "rock,paper and scissors", 9.Next Steps of javascript..It will be helpful..Thanks!!



Here on the Codecademy forum we don't post in full code as we help each other here, we can guide you, give you tips and help you find your mistakes.

So paste in what code you have, error msg and we will gladly assist you.

How to use this forum - How to post code



For the first part you can choose either to 1) call the compare(choice1, choice2) function and keep the program going until a valid option is chosen or 2) end the program and tell the user about the wrong input. Like this:

else {
        console.log("Invalid input by the user.");
        console.log("Please choose a valid option");
        return "Error: Invalid user input.";

For the second part you would just need to repeat the same if/else structure used for Rock, Paper and Scissors.

And for the third part I have only substituted

if (choice1 === choice2) {
    return "The result is a tie!";


if (choice1 === choice2) {
    console.log("The result is a tie!");
    console.log("Please choose again.");
    var userChoice = prompt("Do you choose rock, paper or scissors?");
    compare(userChoice, computerChoice);

In this way the program will ask for another input and will call itself again as long as the choices are the same.

PS: This is my first post on the forum and I hope I didn't break any rules posting only code snippets and not full program. :slight_smile:

Stuck, need help

@fmaiabatista Thank you for your help and support!! I really appreciate it :grinning: :beers: