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 trialRyan Timm
Front End Web Development Techdegree Student 4,569 PointsMy answers aren't adding up on the Conditional Code Challenge
Hi,
After having some trouble with this challenge, I went back and followed the teachers solution to see if I could get it to work. The quiz runs, but my answer's are not adding up at all. Could someone please look at my code and point me in the right direction?
// quiz begins, no answers correct
var correct = 0;
//ask questions
var answer1 = prompt("Name our 44th President.");
if (answer1.toUpperCase() === 'President Obama') {
correct += 1;
}
var answer2 = prompt("Name the President during the Gulf War?");
if(answer2.toUpperCase() === 'President Bush') {
correct += 1;
}
var answer3 = prompt("Name the President who had polio?");
if(answer3.toUpperCase() === 'President Roosevelt') {
correct +=1;
}
var answer4 = prompt("Name the President who could not tell a lie?");
if(answer4.toUpperCase() === 'President Washington') {
correct += 1;
}
var answer5 = prompt("Name our most current President who was impeached.");
if(answer5.toUpperCase() === 'President Clinton') {
correct += 1;
}
//output results
document.write("<p>You got " + correct + " out of 5 questions correct.<p>");
//output rank
if ( correct === 5 ) {
document.write("<p><strong>You earned a gold crown!</strong></p>");
} else if ( correct >= 3 ) {
document.write("<p><strong>You earned a silver crown.</strong></p>");
} else if (correct >= 1 ) {
document.write("<p><strong>You earned a bronze crown.</strong></p>");
} else {
document.write("<p><strong>No Crown for you. You need to study.</strong></p>");
}
2 Answers
james south
Front End Web Development Techdegree Graduate 33,271 Pointsyou are comparing the entered answers, converted to upper case, against strings that are not upper case.
Ryan Timm
Front End Web Development Techdegree Student 4,569 PointsThanks James! I knew it had to be something easy. I feel dumb for missing that! I appreciate the help!