Okay, training wheels off. Let’s see your stuff!

i = 3 while i > 0 do print i i -= 1 end
  1. In the above example, we create a variable called i and set it to 3.
  2. Then, we print out 321 since we execute the loop as long as i is positive.



Use a while loop to print out the numbers 1 through 50, inclusive. While the example above counts down, you will want to count up.Use print rather than puts, and don’t forget to increment your variable.

Folder Icon

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Already have an account?