var noun;
var verb;
var adverb;
var adjective;
var pronoun;
var questions = 5; //this number can adjust
var paragraph;
var noun = prompt("Type Noun");
if (isNaN(noun) == "True"){
questions -= 1;
verb = prompt("Type Verb");
}else{
alert("You entered a number, please enter a Noun.");
}
if (isNaN(verb) == "True"){
questions -= 1;
adverb = prompt("Type Adverb");
}else{
alert("You entered a number, please enter a Verb.");
}
if (isNaN(adverb) == "True"){
questions -= 1;
adjective = prompt("Type Adjective");
}else{
alert("You entered a number, please enter a Adverb.");
}
if (isNaN(pronoun) == "True"){
questions -= 1;
}else{
alert("You entered a number, please enter a Pronoun.");
}
所以主要的想法是让用户输入一个单词。 由于某种原因,它标记布尔值为false并直接进入else语句.....
答案 0 :(得分:1)
这是因为isNaN("某些文字")返回一个布尔值true / false - 和true ==" True"返回false。您的陈述应为:
$(function() {
$('#user').keyup(function(e) {
var $items = $('#item li');
var val = this.value;
var $newItems = $items.each(function(i, item) {
if (!val || $(item).text().indexOf(val) === -1) {
$(item).addClass('hidden');
} else {
$(item).removeClass('hidden');
}
})
});
});