Make a Pizza explainer

The aim of this puzzle: Make a list (array) of toppings (strings) to add to a pizza.

Walkthrough of the solution: The cook() function is ready to bake the toppings onto a pizza but right now toppings is just ‘cheese’.

First, tap on the string ‘cheese’ to highlight it. Next, tap the [] button to replace ‘cheese’ with an empty array []. Now tap the str button to open the keyboard and type in the name of an ingredient like 'ham' or 'pineapple'. Tap the empty space below the new ingredient you just entered and add another.

Once you have at least 3 strings inside the toppings array, try running the code to make your pizza.

Sample code solution:
(Tap below to reveal)

var toppings = [

JavaScript Concepts: Data Structures (arrays), Variable Declaration, Calling Functions, Identifiers
Additional Code (hidden code that runs before the puzzle’s code):

const cook = input => {
      ? `That isn't an array.`
      : input.filter(i=>typeof i === 'string').length !== input.length
        ? `The array should only contain strings.`
        : input.length < 3 
          ? `The array has ${input.length} item${input.length===1?'':'s'}. It needs ${3-input.length} more.`
          : `${input.join` + `}...completes the pizza!`
1 Like