FAQ: Loops - Looping in Reverse


#1

This community-built FAQ covers the “Looping in Reverse” exercise from the lesson “Loops”.

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

Web Development

Introduction To JavaScript

FAQs on the exercise Looping in Reverse

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

Why is it not possible, in this exercise, to set counter = 0 ? Why must it be >= 0?


#3

for (let counter = 3; counter >= 0; counter–){
console.log(counter)
};
works, but for me the loop should be stopping after one (or possibly no) iteration because 2 (or 3) >= 0.

should the >= not be <=?

Am I being stupid??


#4

What does the for-loop do with the code you put there? (Seems like you’ve proved to yourself it doesn’t do what you expect. Time to look it up!)


#5

Ah I was being stupid.

Don’t mind me!


#6

I did

for (let counter = 3; counter > -1; counter--){
  console.log(counter);
}

It works, but the answer is marked as wrong…


#7

Hello, just a beginner myself, but I think I can help.

“a stopping condition is the condition that the iterator variable is evaluated against— if the condition evaluates to true the code block will run, and if it evaluates to false the code will stop.”

If you set your stopping condition to counter === 0, then the condition with evaluate to false right away and your code will never run…