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
Anna Neyman
6,157 PointsMy quiz doesn't add the score and is keep on returning 0. Why?
// score
var counter = 0;
// question 1
var q1 = prompt("Is NYC in the United States?");
if (q1.toUpperCase === "YES"){
counter += 1;
}
// question2
var q2 = prompt("Is Natasha Lyonne an actress?");
if (q2.toUpperCase === "YES"){
counter += 1;
}
// question3
var q3 = prompt("Is the sun hot?");
if (q3.toUpperCase === "YES"){
counter += 1;
}
// question4
var q4 = prompt("Is Berlin in England");
if (q1.toUpperCase === "NO"){
counter += 1;
}
// question5
var q5 = prompt("How many fingers do you have?");
if (q1.toUpperCase === "TEN" || q1 === "10"){
counter += 1;
}
// score to document
document.write("You got " + counter + " questions right!");
// crown to document
if (counter === 5){
document.write(" You got a gold crown!");
}
else if (counter >= 3){
document.write(" You got a silver crown!");
} else if (counter >= 1){
document.write(" You got a bronze crown!");
} else (document.write(" Sorry, you don't get a crown! "))
1 Answer
Per Karlsson
12,683 PointsYou've forgotten your parenthesis on toUpperCase.
Like this:
q1.toUpperCase() === "YES"
Anna Neyman
6,157 PointsAnna Neyman
6,157 PointsThank you!