-
-
Save JProure07200/34a8664ce1eb913575b6e5d71763142c to your computer and use it in GitHub Desktop.
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
console.log("Bienvenue dans ce jeu de devinette !"); | |
let solution = Math.floor(Math.random(1 < 100) * 100) + 1; | |
let NombreEssai; | |
for (NombreEssai = 0; NombreEssai < 6; NombreEssai++) { | |
let proposition = Number(prompt("Proposer un chiffre entre 1 et 100")); | |
if (proposition === solution) { | |
console.log("Bravo, la solution est " + solution + ". Vous avez trouvé en " + NombreEssai + " essai(s)"); | |
break; | |
} else if (proposition < solution) { | |
console.log(proposition + " est trop petit"); | |
} else if (proposition > solution) { | |
console.log(proposition + " est trop grand"); | |
} | |
} | |
if(NombreEssai === 6) console.log("Vous avez perdu... La solution était " + solution + "."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment