Created
November 27, 2019 12:24
-
-
Save bu7ch/cb748125b6243121117ea0af542ac44f to your computer and use it in GitHub Desktop.
correction du jeu devine (Plus ou Moins)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nbTours = 10; | |
const aleatoire = Math.round(Math.random() * 100); | |
console.log('nombre à trouver:', aleatoire); | |
for (let i = 0; i < nbTours; ++i) { | |
const joueur = prompt('devinez le nombre'); | |
if (joueur > aleatoire) { | |
alert('Plus petit'); | |
} else if (joueur < aleatoire) { | |
alert('Plus grand'); | |
} else if (joueur == aleatoire) { | |
alert('Bravo !'); | |
break; // sort de la boucle avant la fin | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment