Challenge Shopping List - ashish9342/FreeCodeCamp GitHub Wiki
🚩 Remember to use Read-Search-Ask
if you get stuck. Try to pair program 👥 and write your own code 📝
Create a shopping list in the variable myList. The list should be a multi-dimensional array containing several sub-arrays.
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. ["Chocolate Bar", 15]
.
There should be at least 5 sub-arrays in the list.
- myList should be an array.
- The first elements in each of your sub-arrays must all be strings.
- The second elements in each of your sub-arrays must all be numbers.
- You must have at least 5 items in your list.
A multi-dimensional array would have the following outline [[]]
.
try to solve the problem now
Each sub-array should be separated by ,
as would any item in an array.
try to solve the problem now
Don't forget the ;
at the end of your declaration.
try to solve the problem now
Solution ahead!
var myList = [["Canned Beans", 3],["Milk Galon", 1],["Cereal", 2],["Toilet Paper", 12],["Sack of Rice", 1]];
- A multi-dimensional array is created.
- The array consists five arrays inside, each composed of a string and an integer, in the same order.
If you found this page useful, you may say thanks to the contributors by copying and pasting the following line in the main chat:
Thanks @Rafase282 for your help with Checkpoint: Shopping List
⚠️ DO NOT add solutions that are similar to any existing solutions. If you think it is similar but better, then try to merge (or replace) the existing similar solution.- Add an explanation of your solution.
- Categorize the solution in one of the following categories — Basic, Intermediate and Advanced. 🚥
- Please add your username only if you have added any relevant main contents. (:warning: DO NOT remove any existing usernames)
See 👉
Wiki Challenge Solution Template
for reference.