Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
639 B
9
Indexable
Never
// lista de cuvinte
let words = ["martie", "caine", "pisica", "casa", "avion", "calculator"];
// alege aleator o pozitie din lista
let pos = Math.floor(Math.random() * words.length);
// cuvantul ales aleator
let word = words[pos];
console.log(word);

// lista de hinturi
let hint = [];
for (let i = 0; i < word.length; i++) {
  hint[i] = "_";
}

console.log(hint);

let tries = 5;
let letters = word.length;

while (tries > 0 && letters > 0) {
  alert("Ghiceste cuvantul ales. Ai " + tries + " incercari la dispozitie.");
  alert(hint.join(" "));
  let guess = prompt("Introdu o litera sau un cuvant");
  break;
}
Leave a Comment