+ 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

10th Nov 2017, 9:42 PM
Bogdan Saliuk
Bogdan Saliuk - avatar
5 Respostas
10th Nov 2017, 11:40 PM
Kamil
Kamil - avatar
+ 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
10th Nov 2017, 10:12 PM
Kamil
Kamil - avatar
+ 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
10th Nov 2017, 11:23 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
You also have a bug as 0 is valid, but not in the 1 to 20 range.
11th Nov 2017, 12:24 AM
John Wells
John Wells - avatar
0
you can use if condition with goto loop, it is very useful for you in this case.
11th Nov 2017, 4:19 AM
M.Laith Shalaty
M.Laith Shalaty - avatar