Ruby - Loops and Iteration
What is the output of this Ruby code?
fruits = ['apple', 'banana', 'cherry']
fruits.each { |fruit| puts fruit.upcase }fruits = ['apple', 'banana', 'cherry']
fruits.each { |fruit| puts fruit.upcase }each does with puts fruit.upcaseeach method runs the block for each fruit, printing the uppercase version.each prints uppercase fruits [OK]puts prints each item on a new line [OK]each returns a new arrayputs with returning a list15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions