Simple Arrays

Posted by Alejandro Sabogal on May 22, 2018

An Array is collection of data. Think of an Array as a container where you can store pieces of information.

Imagine for example your refrigerator. When you return home after shopping at the market, you store most of that food in the refrigerator so it doesn’t go bad. In this situation, your refrigerator is the Array and the food is the data; the Array stores the data you just got.

The data an Array holds can be almost anything. It can be a collection of words (known as Strings), numbers (Integers and Float numbers), other Arrays, and Hashes (a data structure).

Arrays are very important. New students will realize they will be using them constantly to keep track of information. One of the great things about Arrays, is how they can be manipulated. There are several “methods” in Ruby and JavaScript that help you with manipulating the data in the Array. For example, if you have a collection of numbers and you need to sort them, there is a “.sort” method that will help you achieve this. If you want to check if any of these numbers is an even number, there is method for that too.

Tip: Spend a lot of time perfecting the concept of Arrays and learning as many methods as you can. This only comes with practice in reality. Codewards.com is a great place to get this practice.