Skip to content

Instantly share code, notes, and snippets.

@bu7ch
Created November 27, 2019 12:24
Show Gist options
  • Save bu7ch/cb748125b6243121117ea0af542ac44f to your computer and use it in GitHub Desktop.
Save bu7ch/cb748125b6243121117ea0af542ac44f to your computer and use it in GitHub Desktop.
correction du jeu devine (Plus ou Moins)
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