Computer Science Heroes explainer

Aim of the puzzle:
Use the .unshift() method to add an item to the front of an array.

Walk through of solution:
The .unshift() method adds an item to the front of an array. To use it, attach .unshift() to the array you want to alter. Inside the parentheses, put the item you want to insert at the beginning of the array.

In the code that you start off with, there is an array, computerScienceHeroes, and a for…of loop. The for…of loop iterates through the computerScienceHeroes array and logs each item to the console. In this puzzle, you’ll use .unshift() to add a name to the front of the computerScienceHeroes array.

To complete the puzzle, attach .unshift() to the computerScienceHeroes variable that’s on its own line. Add the string 'Grace Hopper' as the argument. Now, when you run the code you’ll see that 'Grace Hopper' has been added to the beginning of the computerScienceHeroes array.

Sample code solution:

let computerScienceHeroes = ['Ada Lovelace', 'Annie Easley', 'Radia Perlman']

computerScienceHeroes.unshift('Grace Hopper');

for (let hero of computerScienceHeroes){

Javascript Concepts: Array Methods, .unshift(), For…Of Loop, console.log(), Variable, String, Array