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
57 lines
1.2 KiB
Markdown
57 lines
1.2 KiB
Markdown
---
|
|
id: bd7993c9c69feddfaeb8bdef
|
|
title: Store Multiple Values in one Variable using JavaScript Arrays
|
|
challengeType: 1
|
|
forumTopicId: 18309
|
|
dashedName: store-multiple-values-in-one-variable-using-javascript-arrays
|
|
---
|
|
|
|
# --description--
|
|
|
|
With JavaScript `array` variables, we can store several pieces of data in one place.
|
|
|
|
You start an array declaration with an opening square bracket, end it with a closing square bracket, and put a comma between each entry, like this:
|
|
|
|
```js
|
|
const sandwich = ["peanut butter", "jelly", "bread"];
|
|
```
|
|
|
|
# --instructions--
|
|
|
|
Modify the new array `myArray` so that it contains both a string and a number (in that order).
|
|
|
|
# --hints--
|
|
|
|
`myArray` should be an array.
|
|
|
|
```js
|
|
assert(typeof myArray == 'object');
|
|
```
|
|
|
|
The first item in `myArray` should be a string.
|
|
|
|
```js
|
|
assert(typeof myArray[0] !== 'undefined' && typeof myArray[0] == 'string');
|
|
```
|
|
|
|
The second item in `myArray` should be a number.
|
|
|
|
```js
|
|
assert(typeof myArray[1] !== 'undefined' && typeof myArray[1] == 'number');
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```js
|
|
// Only change code below this line
|
|
const myArray = [];
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```js
|
|
const myArray = ["The Answer", 42];
|
|
```
|