Ruby - Loops and Iteration
Which of the following is the correct way to write a
while loop in Ruby that prints numbers from 1 to 3?while loop in Ruby that prints numbers from 1 to 3?i = 1 before the loop starts.while syntaxwhile condition do ... end or while condition ... end without braces.i += 1 to increment; i++ is invalid in Ruby.i = 1 while i <= 3 puts i i += 1 endis the correct syntax.
15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions