Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "use strict";
- function jeuPendu() {
- let mots = ["poule", "technologie", "magasin", "ordinateur", "carnet", "microscope", "ananas", "chevalier", "melancolie", "sapin", "bracelet", "herisson", "dinosaure", "programme", "oreiller"];
- let random = Math.round(Math.random() * mots.length);
- let secret = mots[random];
- let trema = "_ ";
- let found = 0;
- let lettre;
- let i;
- let affichage;
- let newaffichage;
- console.log("Bienvenue au jeu du pendu, tentez de retrouver mon mot secret !");
- affichage = trema.repeat(secret.length);
- console.log(affichage);
- while ( found < secret.length) {
- lettre = prompt("Entrez une lettre");
- for ( i = 0; i < secret.length; i++) {
- if (secret[i] === lettre) {
- newaffichage = affichage.replace(affichage[i-1], secret[i]);
- found = found++;
- console.log(newaffichage);
- }
- }
- }
- }
- console.log(jeuPendu());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement