Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCody Garrett
2,103 PointsUltimate quiz challenge, doesn't recognize correct answer.
My program does not recognize that I have entered in the correct answer for any questions and always come back with 'you answered 0/5 questions correctly'. It also doesn't add to the 'score' variable. I'm assuming that is because it doesn't recognize yes or y, but idk if it's just something i messed up with the 'score' variable itself. Any help is appreciated. Thank you.
The question blocks look like this:
var questionOne = prompt('Is this the first question? [Current Score: ' + score + ']'); if ( questionOne.toLowerCase === 'yes' || questionOne.toLowerCase === 'y') { score += 1; }
2 Answers
Maximillian Fox
Courses Plus Student 9,236 PointsFirst of all, you need to look at your toLowerCase method - this is a method (like a function) and NOT a property of your string, so you need to add brackets after it, like this:
questionOne.toLowerCase()
Currently the conditional will never return true. Also, check that console for any additional bugs in your code. Keep going! :)
Steven Parker
231,236 Points Even though the toLowerCase method doesn't use an explicit argument, you still need to add parentheses to indicate that you are calling it: toLowerCase()
.
Without them, you are just naming it. The name would be "truthy", but that fails an identity comparison with a string.