Learn

The complement to the while loop is the until loop. It’s sort of like a backward while:

i = 0 until i == 6 i = i + 1 end puts i
  1. In the example above, we first create a variable i and set it to 0 (zero).
  2. Then we execute a block of code until i is equal to 6. That block of code increments i.
  3. When i is equal to 6, the block ends.
  4. Finally, we print 6, the value of i, to the console.

Instructions

1.

On line 2, fill in the __ blank so that the loop breaks when counter is greater than 10.

On line 5, increment counter like we do in the example above.

Take this course for free

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

Or sign up using:

Already have an account?