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

John Park
John Park
4,368 Points

Javascript: The Conditional Challenge Syntax Error message

Working on the Javascript: Conditional Challenge. But I am not sure why I am getting a syntax error. for my first if statement. Can someone tell me why?

//Score Card
var correct = 0

//Questions
var soccer = prompt("Which country has won the most World Cups?");
var mlb = prompt("What MLB team play in Los Angeles?");
var nfl = prompt("What NFL team play in Atlanta?");
var racket = prompt("What what sport plays with racket?");
var nba = prompt("Who won the 2017 NBA Champtionship?");

//Score and Correct Answer
If (soccer.toUpperCase() === "BRAZIL") {
    correct += 1;
}

2 Answers

Rhys Kearns
Rhys Kearns
4,976 Points

Your error was that the IF statement was capitilised whilst it should be both lower case like - if () instead of If()

Rhys Kearns
Rhys Kearns
4,976 Points

try:

//Score Card
var correct = 0;

//Questions
var football = prompt("Which country has won the most World Cups?").toUpperCase();

//Score and Correct Answer
If (football === "BRAZIL") {
    correct += 1;
};
John Park
John Park
4,368 Points

Rhys,

I tried your suggestion but i also get a syntax error Uncaught SyntaxError: Unexpected token {

Rhys Kearns
Rhys Kearns
4,976 Points
var correct = 0;
var football = prompt("Which country has won the most World Cups?");

if (football.toUpperCase() === "BRAZIL") {
   correct++;
}

Im not sure if im missing a tiny detail ehre but try this?? Not sure.

John Park
John Park
4,368 Points

Rhys,

Thanks man appreciate your help. I was stupid and capitalize the "I" in "If". Which is why the syntax error keep popping up. Appreciate your help.