dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
66 lines
1.1 KiB
Markdown
66 lines
1.1 KiB
Markdown
---
|
|
id: 56533eb9ac21ba0edf2244bc
|
|
title: Shopping List
|
|
challengeType: 1
|
|
forumTopicId: 18280
|
|
dashedName: shopping-list
|
|
---
|
|
|
|
# --description--
|
|
|
|
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.
|
|
|
|
```js
|
|
["Chocolate Bar", 15]
|
|
```
|
|
|
|
There should be at least 5 sub-arrays in the list.
|
|
|
|
# --hints--
|
|
|
|
`myList` should be an array.
|
|
|
|
```js
|
|
assert(Array.isArray(myList));
|
|
```
|
|
|
|
The first elements in each of your sub-arrays should all be strings.
|
|
|
|
```js
|
|
assert(myList.every(elem => elem && typeof elem[0] === 'string'));
|
|
```
|
|
|
|
The second elements in each of your sub-arrays should all be numbers.
|
|
|
|
```js
|
|
assert(myList.every(elem => elem && typeof elem[1] === 'number'));
|
|
```
|
|
|
|
You should have at least 5 items in your list.
|
|
|
|
```js
|
|
assert(myList.length > 4);
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```js
|
|
const myList = [];
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```js
|
|
const myList = [
|
|
["Candy", 10],
|
|
["Potatoes", 12],
|
|
["Eggs", 12],
|
|
["Catfood", 1],
|
|
["Toads", 9]
|
|
];
|
|
```
|