0
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.");
}

So the main idea is to have the user input a word. For some reason it marks the boolean false and goes directly into the else statement.....

3
  • Which boolean does it mark as false? Commented Apr 15, 2017 at 3:24
  • As it iterates through each one, so the initial one was marked false. Then it skips to each else statement, skipping the if statement. Commented Apr 15, 2017 at 3:31
  • what is the requirement & expected result? Commented Apr 15, 2017 at 3:34

1 Answer 1

1

This is because isNaN("some text") returns a boolean true/false -- and true == "True" returns false. Your statements should read:

if (isNaN(noun) === true) {
}
....
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.