Menu
Coddy logo textTech

Add Item

Part of the Fundamentals section of Coddy's JavaScript journey — lesson 72 of 77.

challenge icon

Challenge

Easy

Now, add a function named addItem that gets a string (the item) and pushes it into the ingredients list.

In the end, the function will output:

Milk added to the grocery list.

For the input "Milk".

 

Add the following code at the end of your code to test it:

addItem("Milk");
addItem("Bread");
addItem("Eggs");

Try it yourself

// Grocery list array
let groceryList = [];

All lessons in Fundamentals