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

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge

Daniel Bateman
Daniel Bateman
13,268 Points

Started 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
Wayne Topp
948 Points

I 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
Kieran Barker
15,028 Points

You’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.