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 trialApril Nichols
7,259 PointsCode runs, but correct answers don't tally up.
I tried double-checking my code against the video, and I haven't found an error yet. It takes me all the way through the quiz, but it tells me I got 0 answers right even though I answered all 5 correctly. Help?
jake feaster
1,102 Pointsdid you use the .toUpperCase ? Make sure your else if statements are correctly set, thats what was wrong with my code. Hopefully you figure it out!
jake feaster
1,102 Points// quiz begins, no answers correct var correct = 0;
// ask questions var questionOne = prompt("What is the color of a school bus?"); if(questionOne.toUpperCase() === "YELLOW" ) { correct += 1; } var questionTwo = prompt("How do you say hello in spanish?"); if(questionTwo.toUpperCase() === "HOLA") { correct += 1; } var questionThree = prompt("What is the best programming language?"); if(questionThree.toUpperCase() === "JAVASCRIPT") { correct += 1; }
// output Results document.write("<p>You have gotten</p>" + correct + "<p> out of 3 questions.</p>");
// output Rank if(correct === 3) { document.write("<p>Congrats you have earned a golden crown!</p>"); } else if(correct === 2) { document.write("<p>Congrats you have earned a silver crown!</p>"); } else if(correct === 1) { document.write("<p>Congrats you have earned a bronze crown!</p>"); } else { document.write("<p>Oops you have gotten no correct answers, try again!</p>"); }
// Very basic quiz but it runs, hopefully this helps!
1 Answer
Michael Thompson
7,427 PointsMake sure you put .toUpperCase(). The video's code is missing the () at the end of .toUpperCase in all but the first answer so it is the only one gathering your input and assigning it back to the variable. Thus none of your other answers are being stored so it looks like you only got the first question correct. Hope this helped.
Steven Parker
231,269 PointsSteven Parker
231,269 PointsTo facilitate an analysis and answer, please show your code (formatted for markdown). Better yet, make a snapshot of your workspace and post the link to it.