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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![tako izu](https://uploads.teamtreehouse.com/production/profile-photos/10752330/micro_IMG_1725.webp)
tako izu
17,645 PointsNot showing how many I got right
I'm making a quiz from JavaScript and when it reaches the end it shows you how many you got right. But it's not showing how many I got. This is the code I did:
var questions = ["What's the capital of France?", "What's 10 * 1000?", "If I have 5 apples in one hand, and 6 apples in the other, how many apples do I have?"]; var answers = ["paris", 10000, "11 apples"]; var answerToThis;
function quiz() { var correct = 0; for (var i = 0; i < questions.length; i += 1) { answerToThis = prompt(questions[i]); if (answerToThis.toLowerCase === answers[i]) { correct += 1; } } document.getElementById("final").innerHTML = "You got " + correct + " question(s) correct."; }
Then it comes up with 'You got 0 questions correct.' even though I got all of them.
1 Answer
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsWhen calling a method, you must put parentheses after the method name even if it takes no arguments (like "toLowerCase()
").
Also, be aware that when using the type-sensitive comparison ("===
"), a string (like you get back from "prompt") will not match a number even if they represent the same value.
tako izu
17,645 Pointstako izu
17,645 PointsThank you for reminding me of that! I forget a lot sometimes... 😂