2018-09-30 23:01:58 +01:00
|
|
|
---
|
|
|
|
id: cf1111c1c11feddfaeb7bdef
|
|
|
|
title: Nest one Array within Another Array
|
|
|
|
challengeType: 1
|
2019-02-14 12:24:02 -05:00
|
|
|
videoUrl: 'https://scrimba.com/c/crZQZf8'
|
2019-07-31 11:32:23 -07:00
|
|
|
forumTopicId: 18247
|
2021-01-13 03:31:00 +01:00
|
|
|
dashedName: nest-one-array-within-another-array
|
2018-09-30 23:01:58 +01:00
|
|
|
---
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --description--
|
|
|
|
|
2020-03-25 08:07:13 -07:00
|
|
|
You can also nest arrays within other arrays, like below:
|
|
|
|
|
|
|
|
```js
|
|
|
|
[["Bulls", 23], ["White Sox", 45]]
|
|
|
|
```
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
This is also called a <dfn>multi-dimensional array<dfn>.</dfn></dfn>
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --instructions--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
Create a nested array called `myArray`.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --hints--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
`myArray` should have at least one array nested within another array.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
```js
|
2020-11-27 19:02:05 +01:00
|
|
|
assert(Array.isArray(myArray) && myArray.some(Array.isArray));
|
2018-09-30 23:01:58 +01:00
|
|
|
```
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --seed--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
## --after-user-code--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
```js
|
2018-10-20 21:02:47 +03:00
|
|
|
if(typeof myArray !== "undefined"){(function(){return myArray;})();}
|
2018-09-30 23:01:58 +01:00
|
|
|
```
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
## --seed-contents--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
// Only change code below this line
|
|
|
|
var myArray = [];
|
|
|
|
```
|
2018-09-30 23:01:58 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --solutions--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
```js
|
|
|
|
var myArray = [[1,2,3]];
|
|
|
|
```
|