Tell us what’s happening:
On step 19, it asks me to replace the first item of my array with “Canola Oil” , but when I enter
shoppingList[0] = “Canola Oil”;
into the program and check my code, it says I did not pass. But when I place this beneath it
console.log(getShoppingListMsg(shoppingList));
and check the log, the array comes out looking correct with “Canola Oil” replacing “Chocolate Cake”. What’s am I missing or is something wrong?
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.");
shoppingList.pop();
console.log(getShoppingListMsg(shoppingList));
console.log("It might be nice to get a dessert.");
shoppingList.unshift("Chocolate Cake");
console.log(getShoppingListMsg(shoppingList));
console.log("On second thought, maybe we should be more health conscious.");
// User Editable Region
shoppingList[0] = "Canola Oil";
console.log(getShoppingListMsg(shoppingList));
//Output: Current Shopping List: Canola Oil,Vegetable Oil,Apples,Grapes,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/135.0.0.0 Safari/537.36
Challenge Information:
Build a Shopping List - Step 19