Welcome to the Treehouse Community
Looking to learn something new?
Rich Zimmerman24,063 Points
It's because you're trying to use parseInt on the response, no matter the question. So if an answer is given that is a string, it will return NaN (Not a number).
It looks like in the video all the questions have answers that are integers, so parseInt works. Whereas you have questions that require strings as answers. So you can just remove the parseInt method and it should work.
Niki Molnar25,575 Points
Remove parseInt() from the response in your for loop, so it should be
response = prompt(question);
Then it works fine
Justin HornerTreehouse Guest Teacher
I've forked the Workspace and modified it to do what you want, I believe. I left a few comments to explain the changes. Please feel free to contact me if you have questions.
You can checkout the updated Workspace here.
I hope this helps.
Happy Coding :)
Hi Alex, I can maybe help you by pointing that you're using the || operator in a way that doesn't fit your expectation. When you write this :
var questions = [ ["What is the name of Han Solo's ship?", "The Millenium Falcon" || "the millenium falcon" || "Millenium Falcon" || "millenium falcon"], ["How fast did it make the Kessel Run?", "12" || "12 parsecs" || "12 Parsecs"], ["Was it fast enough for you old man?", "Yes" || "yes"] ];
var questions = [ ["What is the name of Han Solo's ship?", "The Millenium Falcon"], ["How fast did it make the Kessel Run?", "12"], ["Was it fast enough for you old man?", "Yes"] ];
o1 = true || true // t || t returns true o2 = false || true // f || t returns true o3 = true || false // t || f returns true o4 = false || (3 == 4) // f || f returns false o5 = 'Cat' || 'Dog' // t || t returns "Cat" o6 = false || 'Cat' // f || t returns "Cat" o7 = 'Cat' || false // t || f returns "Cat" o8 = '' || false // returns false o9 = false || '' // returns ""
I hope it helped.