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 Solution

Guys what is wrong in this simple code?

// Total score
var correct=0;
//Questions 
var question1 = prompt("One or two?");
if (question1.toUpperCase ==='ONE'){
correct += 1;
}
var question2 = prompt("Two or three?");
if (question2.toUpperCase ==='TWO'){
correct += 1;
}
var question3 = prompt("Three or four?");
if (question3.toUpperCase === 'FOUR'){
correct += 1;
}
//Results
document.write(correct);

if(correct === 3){
document.write("<p>Golden</p>");
}
else if(correct >= 2){
document.write("<p>Not Bad</p>");
}
else if(correct >=1 ){
document.write("<p>Bad</p>");
}
else{
document.write("<p>Very bad</p>";)
}

3 Answers

Steven Parker
Steven Parker
229,788 Points

On the last line there's a syntax error where the semicolon is inside the parentheses.

Also, to call the toUpperCase method, you must have a pair of parentheses after the name. Otherwise, you're comparing the method itself with the correct answer (which will never match).

omg... It happened again!

Hello Phillipp,

Could you provide some context as to what you think is wrong with your code? Is there something specific not working?

I'd recommend taking a look at this line:

document.write("<p>Very bad</p>";)

Happy coding!

Thank you!!) pair of parentheses after toUpperCase method solved the issue.