Aim of the puzzle: Use the
.unshift() array method to add an element to the beginning of an array.
Walk through of solution: The
.unshift() array method is used to add an element to an array. It is similar to
.push(), except it adds an element to the front of an array rather than the end.
In this puzzle, the
line array contains the strings
newPerson contains the string
To complete the puzzle, use
.unshift() to help Zeke get to the front of the line.
In between the 2 console.log statements, add
.unshift(newPerson) to the end of
line. This will add
newPerson to the front of
Sample code solution:
let line = ['Alice', 'Bobby', 'Charlie']; let newPerson = 'Zeke'; console.log(line + ' is at the front of the line.'); line.unshift(newPerson); console.log(line + ' is at the front of the line.');