Files
tp-algorithmique/algo_js/nombre_cache.js
2025-04-02 11:33:15 +02:00

17 lines
514 B
JavaScript

const prompt = require('prompt-sync')();
// Deviner le nombre caché
let nombreCache = Math.floor(Math.random() * 100);
let propostion = parseInt(prompt("Devinez le nombre caché entre 1 et 100 :"));
while (propostion != nombreCache) {
if (propostion < nombreCache) console.log("C'est plus grand !");
else if (propostion > nombreCache) console.log("C'est plus petit !");
propostion = prompt("Réessayez :");
}
if (propostion == nombreCache) console.log("Bravo ! Vous avez deviné le nombre caché !");