What if the game didn't end there but instead asked both players for new choices?


#1



I figures out that I could use a loop, maybe a while loop? But after trying different ways to implement it since last night, I got stuck. Please enlighten me someone on where to implement the loop and which loop to use.


Replace this line with your code.


#2

you could place a do while loop around the whole thing:

do {
  prompt user
  computerchoice
  compare function
  prompt if the user want to play again (y/n)
} while(again == 'y')

#3

I did the following code, and it works partially, the only problem is that when I say "y" to the prompt request, it does not open up a new game, it just says: congrats you completed the course..

do {

// run first part of the existing code..

var compare = function(choice1, choice2) {
if (choice1 === choice2) {
prompt("Do you want to play again - y/n?");
}

// run last part of the existing code..

} while(compare == 'y')

Did I do something wrong or is it just the way the tutorial works?


#4

can i see the full code you have? I can't tell what the problem is without the full code


#5

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