freeCodeCamp Challenge Guide: Shopping List

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.

Relevant Links

6 Likes

This Basic Code Solution doesn’t end the array the way I would expect (as noted in the hints!) there is no ; ? am I missing something?

1 Like

Maybe you’re viewing this on a smaller screen? The semicolon is at the end of the line as it is supposed to be. You might need to side scroll to see it :slight_smile:

1 Like