Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor
Learn
Data Structures

Iterating Over Arrays

Iterating over arrays is easier than it looks.

numbers = [1, 2, 3, 4, 5] numbers.each { |element| puts element }
  1. In the example above, we create an array called numbers with 5 elements.
  2. Then we say, "Take this array and for each element, print it to the console." As usual, we can use any placeholder name for the bit between two | | characters.
Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.