Build a Shopping List - Step 5

Tell us what’s happening:

I can’t understand the prob. They say “Your getShoppingListMsg function should accept an array as an argument.”

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");


// User Editable Region

function getShoppingListMsg(shoppingList) {
  return "Current Shopping List: " + shoppingList.join(", ");
}



// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15

Challenge Information:

Build a Shopping List - Step 5

Hi,
Why are you using the .join()?

the thing is my code was not passing, so ask chat, and she said to write that

Actually, your code passes without using the .join() method.
In this step, you just need to concatenate the text and the array using +.
I hope this helps!

Yeah, I removed it, and it passed. thanks

1 Like