More Ice Cream Please explainer


#1

The aim of this puzzle: Add another ice cream flavor to the end of array.

Walkthrough of the solution: The .push() array method is used to add an item to the end of an array. In this puzzle, we’ll use it to add a string.

Inside of the parentheses of .push(), double tap the quote marks to edit the string. Enter any ice cream flavor, for example, 'butter pecan'.

Sample code solution:
(Tap below to reveal)

import { listOfIceCreams } from 'grasshopper.treats';

listOfIceCreams.push('butter pecan');

for (let flavor of listOfIceCreams) {
  console.log(flavor);
}

JavaScript Concepts: Array Methods, .push(), console.log(), For…of Loops, Strings