Ruby - Loops and Iteration
What is the output of this Ruby code?
result = []
3.upto(5) { |i| result << i * 2 }
puts result.join(",")result = []
3.upto(5) { |i| result << i * 2 }
puts result.join(",")i takes values 3, 4, and 5.i is multiplied by 2 and added to result: 6, 8, 10.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions