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 trialLucas Guimarães
Front End Web Development Techdegree Student 3,900 PointsI did with a conditional to give more change for the user`s answer.
I have to admit that was a little bit difficult for me. Because when my code was running to sum all the score, for some reason it was adding 2, even I got all wrong. I figured out I forgot to include parentheses for the conditional and that was sorted of my problem.
Follow my code. PS: I am really really really bad to make questions :(
var questionOne = prompt("Which program laguange is the best one ?");
questionOne = questionOne.toUpperCase();
var questionTwo = prompt("What\`s name of our planet ?");
questionTwo = questionTwo.toUpperCase();
var questionThree = prompt("2 + 2 = ?");
questionThree = parseInt(questionThree);
var questionFour = prompt("four is 1, five is 2, six is ?");
questionFour = parseInt(questionFour);
var questionFive = prompt("From which country is Eminem ?");
questionFive = questionFive.toUpperCase();
var score = 0;
if ((questionOne === "JAVA" || questionOne === "JAVA SCRIPT" || questionOne === "JS" || questionOne === "JAVASCRIPT")) {
score += 1
}
if (questionTwo === "EARTH") {
score += 1
}
if (questionThree === 4) {
score += 1
}
if (questionFour === 3) {
score += 1
}
if ((questionFive === "USA" || questionFive === "UNITED STATES")) {
score += 1
}
var rank= "";
if (score === 5) {
rank = "Gold Crown"
} else if (score >= 3) {
rank = "Silver Crown"
}else if (score >= 1) {
rank = "Bronze Crown"
} else if (score === 0 ) {
rank = "Invisable Crown!!!"
}
document.write("<h2>Your score was " + score + ". You has been awarded with a " + rank + "</h2>");
///