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

Did this challenge the hard way but it worked!

var score = 0;
var gold = 'Gold';
var silver = 'Silver';
var bronze = 'Bronze';
var none = 'no';


var Qone = prompt('What is the state capital of oregon?');
  if (Qone.toUpperCase() === 'SALEM'){ 
    score += 1;
    alert('Correct, your score is now ' + score )
       } else{
    score = score + 0 
    alert('Sorry not correct your score is ' + score )
}
var Qtwo = prompt('What is the first name of the of Captian Kirk from Star Trek?');
    if (Qtwo.toUpperCase() === 'JAMES'){  
    score += 1;  
    alert('Correct, your score is now ' + score )
}  else{
    score = score + 0 
    alert('Sorry not correct your score is ' + score )
}
var Qthree = prompt('What is the University of Oregons mascot?');
  if (Qthree.toUpperCase() === 'DUCK'){
    score += 1;
    alert('Correct, your score is now ' + score )
} else{
    score = score + 0 
    alert('Sorry not correct your score is ' + score )
}
var Qfour = prompt('Who makes the the ios opperating system?');
  if (Qfour.toUpperCase() === 'APPLE'){  
    score += 1;
    alert('Correct, your score is now ' + score )
    } else{
    score = score + 0 
    alert('Sorry not correct your score is ' + score )
    }
var Qfive = prompt('What kind of dog was lassie?');
  if (Qfive.toUpperCase() === 'COLLIE'){ 
    score = score +1

  if (score === 5){
var crownType = gold

} else if(score === 4 || score === 3){ 
    crownType = silver

} else if(score === 2 || score === 1){ 
    crownType = bronze    

} else if(score === 0){ 
    crownType = no 
}    
    alert('Correct you are all done!\n\nYou have a total of ' + score + ' points' + ' and you have a ' + crownType + ' crown')

} else{
    score = score + 0 
      if (score === 5){
var crownType = gold

} else if(score === 4 || score === 3){ 
    crownType = silver

} else if(score === 2 || score === 1){ 
    crownType = bronze    

} else if(score === 0){ 
    crownType = no 
}  
    alert('Sorry not correct your score is ' + score + ' and you have a ' + crownType + ' crown.' )
}

1 Answer

Liam Maclachlan
Liam Maclachlan
22,805 Points

Haha :)) Yeah. As long as the output of the code is correct, generally you can get away with unique/workaround/hack methods. It's great, if like me, you like to stray off the beaten path :)