FAQ: Conditional Statements - Else If Statements


#1

This community-built FAQ covers the “Else If Statements” exercise from the lesson “Conditional Statements”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Introduction To JavaScript

FAQs on the exercise Else If Statements

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


#2

I don’t remember being taught this. If you place a backslash before a single apostrophe does it indicate that it is part of the string and not an indicator of where a string starts and stops?


#3

you seem to understand it correctly, even though it might or might have been taught.

personally, i would then just enclose the string in quotation marks:

console.log("i'm clever");

even simpler


#4

Is there a way to change the variable season (in the code below) using a particular time interval, from summer to spring to fall and back to summer?

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.’);
}
else if (season === ‘fall’) {
console.log(‘It’s fall! Leaves are falling!’)
}
else if (season === ‘summer’) {
console.log(‘It’s sunny and warm because it’s summer!’)
}
else {
console.log(‘Invalid season.’);
}


#5

you could setTimeOut:

https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout

combined with a loop, you might be able to achieve what you want.


#6

ok let me give it a try


#7


#8

Does anybody know what I have done wrong here. 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’);
} else {
console.log(‘Invalid season.’);
}


#9

strings printed/logged need to be an exact match


#10

thanks, missed a dot after ‘snow’.


#11

my point exactly. Good you spotted it