Codecademy Forums

FAQ: Conditional Statements - Else If Statements

There’s no limit to the number of else if statements, but the logic can become unwieldy, and difficult to follow if you get too carried away. Same goes for a switch statement with lots of case:'s. It may be that your code could be refactored to handle the task differently in many situations to avoid this predicament.

1 Like

The escape character is first introduced when the user fails to use it in the solution. It should be introduced to the student before their statement (which was written by the program and not the student) is determined to be wrong.

The definition of Ternary Operator is not clearly outlined in the lesson and must be referenced in a third-party program. The definition of the object we are learning to use should be in the opening of the lesson where its use is discussed.
In the final portion of the lesson where conditionals are reviewed, this sentence appears: “The ternary operator is shorthand to simplify concise if...else statements.” However the operator ? does not appear on the page. It should be added to the definition just as <, >, ||, etc also appear on the page.

I cant understand what i did wrong. can anyone take a look please.

let season = 'summer';

if (season === 'spring') {
  console.log('It\'s spring! The trees are budding!');
} else if(season ==='winter'){
  console.log('It\'s winter! Everything is covered in snow.');
}

Hello, @domwebster. Welcome to the forum.
I can’t tell for sure from your code, but it appears that you have used an apostrophe twice inside of single quotes. Whenever you need to include code in a post, please use the </> button in the menu bar. If you click it first, you can then paste your code in the space indicated, and formatting, special characters, etc. will be preserved.

Try using the escape character \ (backslash) before the apostrophe marks inside your string literals like so:

console.log('It\'s spring! The trees are budding!');

I believe this technique is included in the instructions for the exercise. As you progress through the lessons, you’ll learn other techniques that would eliminate the need for the \.

where is the else clause? It should have been there, you are suppose to add the else if statement, which means you end up with: if statement, else if statement and an else statement.

1 Like