<script>
var words=[
"javascript",
"monkey",
"amazing",
"pancake"
];
var word=words[Math.floor(Math.random()*words.length)];
var answerArray=[];
for(var i=0;i<word.length;i++){
answerArray[i]="_";
}
var remainingLetters=word.length;
while(remainingLetters>0){
};
alert(answerArray,join(" "));
var guess=prompt("Guess a letter,or click cancle to stop playing.");
if(guess===null){
break;
}else if(guess.length !==1){
alert("please enter a single letter.");
}else{
for(var j=0;j<word.length;j++){
if (word[j]===guess) {
answerArray[j]=guess;
remainingLetters--;
}
}
}
}
alert(answerArray.join(""));
alert("Good job! The answer was "+word);
</script>
cnyballk
慕粉3835723
李晓健
相关分类