Loops & Iterators - While - HELP NEEDED, PLS!


#1

Hi!

I’m stuck on 14/18 from loops & iterators. I really didn’t get it… Can someone please help?

Thanks!

Mariana


#2

Let’s start with a link to the exercise, please. Thanks.


#3

https://www.codecademy.com/courses/learn-ruby/lessons/loops-iterators/exercises/looping-with-while?action=lesson_resume


#4

To define a range in Ruby we use .., as in,

a..b

where both a and b are inclusive in the range.

Sorry, that would be the setup of a for loop. I see the instructions ask for a while loop.

We start with an initial value on our counter:

n = 1

Now we set up the while structure,

while 

end

Our condition is n is less than 51, so,

while n < 51

end

Now we are ready for the do and the rest of the code. Remember to increment n (or whatever variable you use) inside the loop, after your print statement.

    n += 1

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.