Build a Shopping List - Step 19

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

Welcome to the forum :wave:

Reset the step, yuo’ve accidentally removed a line that comes after this one

console.log("On second thought, maybe we should be more health conscious.");
1 Like

I attempted to reset the step by going back to step 17. Step 17 asks for a line of text in the console log, and step 18 asks for shoppingList.shift(); but when I move to step 19 it drops the shift line. So what got me through this was including shoppingList.shift(); before the requested array change.

Step 17:
console.log("On second thought, maybe we should be more health conscious.");

Step 18:
shoppingList.shift();

Step 19:

shoppingList.shift();
shoppingList[0] = "Canola Oil";

this is not how you reset the step, you reset the step by using the reset button

Fair enough. I clicked on the reset button, but to me it was ambiguous as to whether it would reset the step or the entire workshop. The word ‘Lesson’ made me worry it was going to make me start completely over.

in that way you are changing step, you are not resetting step 19, to reset step 19 you need to use the reset button in step 19

I went back to the curriculum page and clicked on box 17.

great, so you went back to step 17. That is not resetting step 19, to reset step 19 you need to use the reset button in step 19
This button here
image

Yes. I understand that now. As I said, the wording to me seemed unclear whether it was resetting the step or the entire workshop because of the word ‘Lesson’. Were it me, I would change ‘Lesson’ to ‘Step’ to remove that possible misunderstanding.

Either way, without resetting the lesson, adding the shift line to step 19 let me finish the workshop.