Using Arrays to Group Data
Use arrays to keep track of your data in an orderly fashion.
Arrays are Lists
We use lists every day to keep track of certain information. Lists are great because they contain information we need and are organized in a specific order. Let’s imagine for a second if we had a recipe, but all the steps to make the recipe were scrambled! What good is the recipe if the order isn’t followed?
Now take a look at the following code:
let friedEgg = ['heat up pan', 'add oil to pan', 'crack an egg into the pan', 'cook until yolk is no longer runny'];
As shown by the
friedEgg example, what we actually created is an array. The elements inside are the strings:
'heat up pan',
'add oil to pan', etc… As we dive deeper into arrays, we’ll also cover how to add more elements, retrieve elements, and edit them.
So, if you need to list out your information, look no further than using an array!