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

Not sure why this isn't working, please help!

var score = 0;

var question1 = prompt("Which is the largest continent on earth?'"); if (question1.toUpperCase() === 'AFRICA') { score +=1; } document.write('<p>Your answer if correct!</p>'); } else { document.write('<p>Your anser if wrong.</p>); }

var question2 = prompt('What is the name of our local star?'); if (question2.toUpperCase() === 'SUN') { score +=1; } document.write('<p>Your answer if correct!</p>'); } else { document.write('<p>Your anser if wrong.</p>); }

var question3 = prompt('What is the name of the largest animal to ever live?'); if (question3.toUpperCase === 'BLUE WHALE) { score +=1; } document.write('<p>Your answer if correct!</p>'); } else { document.write('<p>Your anser if wrong.</p>); }

var question4 = prompt('Which is better, PC or Mac?'); if (question4.toUpperCase === 'PC') { score +=1; } document.write('<p>Your answer if correct!</p>'); } else { document.write('<p>Your anser if wrong.</p>); }

var question5 = prompt('What are you writing this code in?'); if (question5.toUpperCase === 'JAVASCRIPT') { score +=1; } document.write('<p>Your answer if correct!</p>'); } else { document.write('<p>Your anser if wrong.</p>); }

document.write('<h2> You got ' + score + ' correct!</h2>'); if (score >4) { document.write(<h2>You got the golden crown!</h2>'); } else if { (score >=3 || score >=4 ) { document.write(<h2>You got second place!</h2>'); } else if (score === 1 || score === 2 ) { document.write(<h2>You got third place!</h2>'); } else if (score <1 ) { document.write('You fucking suck'); }

1 Answer

Looking at the first question,

  1. You are using " and ' at the end of Which is the largest continent on earth?
  2. Make sure to include document.write('<p>Your answer if correct!</p>'); within the if { } statement. Currently, it's outside so it doesn't execute if the condition is met.
  3. Your else statement is missing a ' within the closing parenthesis: </p>')