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

Points are not totaling. I checked mistakes others made.

Hey guys, the problem I'm running into is that the score is not totaling. The game keeps saying no questions were answered correctly. I looked at the corrections for mistakes other people made and I don't see any of those mistakes in my code. Thanks!

// Intro var score = 0; alert("I am going to give you a 5 question quiz about mixed martial arts aka MMA, and if you get enough questions right you might get a crown! Get ready!");

// Question 1 var question1 = prompt("Who was the fighter who became famous as 'The Gracie Killer'?"); if (question1.toUpperCase() === "SAKURABA" || question1.toUpperCase() === "KAZUSHI SAKURABA") { score += 1; }

// Question 2 var question2 = prompt("What female fighter was an Olympic Judo competitor?"); if (question2.toUpperCase() === "ROUSEY" || question2.toUpperCase() === "RONDA ROUSEY") { score += 1; }

// Question 3 var question3 = prompt("Who was the first fighter to win a UFC belt and defend it 3 consecutive times?"); if (question3.toUpperCase() === "ROYCE" || question3.toUpperCase() === "ROYCE GRACIE") { score += 1; }

// Question 4 var question4 = prompt("What is the name of the Dutch championship fighter who is a 5th degree black belt in Kyokushin Karate?"); if (question4.toUpperCase() === "RUTTEN" || question4.toUpperCase() === "BAS RUTTEN") { score += 1; }

// Question 5 var question5 = prompt("How much did the UFC sell for in 2016?"); if (parseInt(question5) === "$4,000,000,000" || parseInt(question5) === "4 billion dollars" || parseInt(question5) === "$4 billion") { score += 1; }

// Point Summary if (score === 5) { document.write("Awesome job. You get the Gold Crown! You know your shit."); } else if (score >== 3) { document.write("You did pretty damn good. Congrats. Silver Crown."); } else if (score >== 1) { document.write("You get the Bronze Crown."); } else (score === 0) document.write("Your total is 0 points. No crown for you!");

Sushant Kumar
Sushant Kumar
Courses Plus Student 3,555 Points

Dear William, in your code there are only two mistake

  1. first is: "else if (score >=="
    --please replace with --- "else if (score >=",

  2. when you are using only else, must not use any type of condition with else: "else (score === 0) document.write("Your total is 0 points. No crown for you!");" --please replace with --- "else {document.write("Your total is 0 points. No crown for you!");}"

1 Answer

Steven Parker
Steven Parker
229,732 Points

There are no strict relational operators in JavaScript.

Unlike equality and inequality, there are no strict versions of the relational operators (like ">=").

And as Sushant pointed out, the plain else statement does not take a conditional expression. It handles all cases not previously covered by if and else if statements.