Shopping List
Hints
Hint 1
A multi-dimensional array would have the following outline [[]]
.
Hint 2
Each sub-array should be separated by ,
as would any item in an array.
Hint 3
Don’t forget the ;
at the end of your declaration.
Solutions
Solution 1 (Click to Show/Hide)
var myList = [
["Canned Beans", 3],
["Milk Galon", 1],
["Cereal", 2],
["Toilet Paper", 12],
["Sack of Rice", 1]
];
Code Explanation
- A multi-dimensional array is created.
- The array consists five arrays inside, each composed of a string and an integer, in the same order.