+ 3
Loop
Hello guys. How can i loop this game? Like 'game over - play again? - yes - new game' https://code.sololearn.com/WxQr29QR62m9/?ref=app
5 Respostas
+ 8
if you need inspiration ^^
https://code.sololearn.com/WNhjXHhpFs43/?ref=app
+ 7
wrap everything in a function named my game
add this function at the bottom of your code
function playAgain(){
if(confirm("Do you want to play one more time?"){
game();
}
}
this will ask the user if he wants to play again and start the function game if he confirms that
put playAgain () after every closing sentence
+ 6
As for your game itself, it is ridiculously unfair as it gives no hints on the next number
Perhaps you can add if the number is > or < than your number
+ 1
You also have a bug as 0 is valid, but not in the 1 to 20 range.
0
you can use if condition with goto loop, it is very useful for you in this case.