Untitled
unknown
plain_text
2 years ago
639 B
17
Indexable
// 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;
}
Editor is loading...
Leave a Comment