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 trialDaniel Bateman
13,268 PointsStarted the challenge, quiz always tells me the answer is wrong. I feel it has to be a syntax error. Any suggestions?
Below is my code:
var tally= 0 var question1= prompt('What animal barks?');
if (question1.toUpperCase === 'DOG') { tally+= 1; alert("you got it right!");
} else { alert("wrong!");
}
var question2= prompt('What color is grass?');
if (question2 === 'GREEN') { tally+= 1; alert("you got it right!");
} else { alert("wrong!");
}
var question3= prompt('How many fingers on a hand?');
if (question2.toUpperCase === 'FIVE' || question2 ===5) { tally+= 1; alert("you got it right!");
} else { alert("wrong!");
}
2 Answers
Wayne Topp
948 PointsI think Kieran's solutions should be correct. Each time you use the string property ".toUpperCase()" you need to make sure to include the parentheses. I've made the same mistake several times in my code already! Here's the corrected code (I think):
var tally = 0;
var question1 = prompt ('What animal barks?');
if (question1.toUpperCase() = 'DOG') {
tally +=1; alert('you got it right');
} else { alert ('wrong');}
etc.
Kieran Barker
15,028 PointsYou’re missing a semicolon after your first variable declaration and you’ll want to check if question2.toUpperCase() === 'GREEN'
. Could these things be the answer? I haven’t actually checked what the challenge is asking for.