2018-09-30 23:01:58 +01:00
|
|
|
---
|
|
|
|
id: cf1111c1c11feddfaeb7bdef
|
|
|
|
title: Nest one Array within Another Array
|
|
|
|
challengeType: 1
|
2020-05-21 17:31:25 +02:00
|
|
|
isHidden: false
|
2019-02-14 12:24:02 -05:00
|
|
|
videoUrl: 'https://scrimba.com/c/crZQZf8'
|
2019-07-31 11:32:23 -07:00
|
|
|
forumTopicId: 18247
|
2018-09-30 23:01:58 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
## Description
|
|
|
|
<section id='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]]
|
|
|
|
```
|
|
|
|
|
|
|
|
This is also called a <dfn>multi-dimensional array<dfn>.
|
2018-09-30 23:01:58 +01:00
|
|
|
</section>
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
<section id='instructions'>
|
|
|
|
Create a nested array called <code>myArray</code>.
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
```yml
|
2018-10-04 14:37:37 +01:00
|
|
|
tests:
|
|
|
|
- text: <code>myArray</code> should have at least one array nested within another array.
|
2019-07-13 00:07:53 -07:00
|
|
|
testString: assert(Array.isArray(myArray) && myArray.some(Array.isArray));
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
```js
|
2020-03-02 23:18:30 -08:00
|
|
|
// Only change code below this line
|
2018-09-30 23:01:58 +01:00
|
|
|
var myArray = [];
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
### After Test
|
|
|
|
<div id='js-teardown'>
|
|
|
|
|
|
|
|
```js
|
2018-10-20 21:02:47 +03:00
|
|
|
if(typeof myArray !== "undefined"){(function(){return myArray;})();}
|
2018-09-30 23:01:58 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
var myArray = [[1,2,3]];
|
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|