Build a Shopping List - Step 14

Tell us what’s happening:

Hello! I need help. Where is problem in this code. Thank you for your help.

Your code so far

console.log("Grocery shopping list");

const shoppingList = [];

console.log("It will be nice to have some fruit to eat.");

shoppingList.push("Apples");

function getShoppingListMsg(arr) {
  return `Current Shopping List: ${arr}`;
}

console.log(getShoppingListMsg(shoppingList));

shoppingList.push("Grapes");
console.log(getShoppingListMsg(shoppingList));

console.log("It looks like we need to get some cooking oil.");

shoppingList.unshift("Vegetable Oil");
console.log(getShoppingListMsg(shoppingList));

shoppingList.push("Popcorn", "Beef Jerky", "Potato Chips");
console.log(getShoppingListMsg(shoppingList));

console.log("This looks like too much junk food.");


// User Editable Region

const shoppingList = ["Grapes", "Vegetable Oil", "Popcorn", "Beef Jerky", "Potato Chips"];
// Use the pop method to remove the last item from the array
shoppingList.pop();
// Log the updated array to the console
console.log(shoppingList);
// Output: [ "Grapes", "Vegetable Oil", "Popcorn", "Beef Jerky" ]

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36

Challenge Information:

Build a Shopping List - Step 14
https://www.freecodecamp.org/learn/full-stack-developer/workshop-shopping-list/step-14

Hi,

You don’t need to create another shoppingList array, it’s already there. Just use the .pop() method.

Reset the lesson and try again.

1 Like