Basic JavaScript - Shopping List

Tell us what’s happening:
help

Your code so far

const myList = 
["Chocolate Bar", ["QTY",1],
"Milk Cartons", ["QTY",1],
"eggs", ["QTY", 30],
"Peanut butter", ["QTY", 2],
"Chicken mix", ["QTY", 3 ]];

Your browser information:

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

Challenge: Basic JavaScript - Shopping List

Link to the challenge:

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

The first element in each sub-array should contain a string with the name of the item. The second element should be a number representing the quantity i.e.

Let’s check your first sub-array and see if it meets the requirements.

The first sub-array is:

["Chocolate Bar", ["QTY",1]

Is the first element of the sub-array a string containing a name?

Yes, "Chocolate Bar" is a string.

Is the second element a number representing the quantity?

No, it is an array (["QTY",1]) with the first element a string (QTY) and the second element a number.

Now that you know what the second sub-array is compared to what it is supposed to be, see if you can solve the challenge now.

1 Like