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 trialJulie Ogden
3,330 PointsHere's my code: for some reason it says "incorrect" when I put in the right answer. Anyone see the problem?
Hi! So for this quiz it's all working well except for deciding whether a questions is right or false. for example:
var answer1 = prompt("What color is the sky?") if (answer1.toUpperCase === "BLUE") { alert("Correct!"); correct += 1; } else { alert("Sorry, that's incorrect."); }
I have tried answering this question with "Blue" "blue" and "BLUE" and none of them work. I get "Sorry that is incorrect" every time. Where did I go wrong in my code?
Thank you very much!
1 Answer
rydavim
18,814 PointsLooks like you just missed some parentheses, toUpperCase is a method call.
var answer1 = prompt("What color is the sky?")
if (answer1.toUpperCase() === "BLUE") { // On this line, make sure you've got () after toUpperCase!
alert("Correct!");
correct += 1;
} else {
alert("Sorry, that's incorrect.");
}
Julie Ogden
3,330 PointsJulie Ogden
3,330 PointsSuch a simple fix! It's working perfectly now. Thank you so much for your speedy response. :)
rydavim
18,814 Pointsrydavim
18,814 PointsAbsolutely! It's super easy to make typos or leave little stuff like that out. Happy coding!
gmyauabalb
3,268 Pointsgmyauabalb
3,268 PointsI had the same issue, thank you for the help!