Learn

Let’s go over what we learned about blocks.

numbers = [5, 2, 8] sum = 0 numbers.each do |n| sum += n end puts sum

The example above is just a reminder about syntax. We calculate the sum of a list of numbers.

Instructions

1.

Add a block after .each that multiplies each item by itself and puts the result to the console.

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?