9. Next Steps


#1

Hi,

Okay, last step, I pretty much did all the other previous steps with barely any help, but this one has really got my scratching my head. The sub tasks I am stuck on:

  • What if a user makes an inappropriate choice like 'dog'? How can we extend the function to handle that?

  • In this version, if both players make the same choice, the game returns a tie. What if the game didn't end there but instead asked both players for new choices?

For the dog one, i'm assuming we would do something similar to this
else if(choice1 === "dog") {
if(choice2 === "scissors") {
return "Invalid choice, please pick Rock, Paper or Scissors";
}
else {
return "Invalid choice please pick Rock, Paper or Scissors";
}

Or maybe, we would have to add a "prompt" function thingy? Not sure, any clarification would be great. But also, does this task mean adding any word or just dog only. because adding another word other than dog is...yh lol

The second task, is something I have no idea, the only thing I can guess is to add another "prompt", but other than that, no clue.

Thanks for your time!


#2

An inappropriate choice would be resolved with just a simple else:

if(choice1 == "rock") {
//some code
} else if(choice1 == "paper") {
//some code
} else if(choice1 == "scissors") {
//some code
} else {
return "Invalid Choice"
}