2021-02-06 04:42:36 +00:00
---
id: bd7993c9c69feddfaeb8bdef
2021-02-21 08:49:16 -07:00
title: Almacena múltiples valores en una variable utilizando los arreglos de JavaScript
2021-02-06 04:42:36 +00:00
challengeType: 1
videoUrl: 'https://scrimba.com/c/crZQWAm'
forumTopicId: 18309
dashedName: store-multiple-values-in-one-variable-using-javascript-arrays
---
# --description--
2021-02-21 08:49:16 -07:00
Con las variables de arreglos (`array` ) de JavaScript, podemos almacenar varios datos en un solo lugar.
2021-02-06 04:42:36 +00:00
2021-02-21 08:49:16 -07:00
Inicias una declaración de arreglo con un corchete de apertura, lo terminas con un corchete de cierre, y pones una coma entre cada entrada, de esta forma:
2021-02-06 04:42:36 +00:00
2021-03-29 22:47:35 +09:00
```js
2021-10-27 15:10:57 +00:00
const sandwich = ["peanut butter", "jelly", "bread"];
2021-03-29 22:47:35 +09:00
```
2021-02-06 04:42:36 +00:00
# --instructions--
2021-06-20 22:29:09 +05:30
Modifica el nuevo arreglo `myArray` para que contenga tanto una cadena como un número (en ese orden).
2021-02-06 04:42:36 +00:00
# --hints--
2021-06-20 22:29:09 +05:30
`myArray` debe ser un arreglo.
2021-02-06 04:42:36 +00:00
```js
assert(typeof myArray == 'object');
```
2021-06-20 22:29:09 +05:30
El primer elemento en `myArray` debe ser una cadena.
2021-02-06 04:42:36 +00:00
```js
assert(typeof myArray[0] !== 'undefined' & & typeof myArray[0] == 'string');
```
2021-06-20 22:29:09 +05:30
El segundo elemento en `myArray` debe ser un número.
2021-02-06 04:42:36 +00:00
```js
assert(typeof myArray[1] !== 'undefined' & & typeof myArray[1] == 'number');
```
# --seed--
## --after-user-code--
```js
(function(z){return z;})(myArray);
```
## --seed-contents--
```js
// Only change code below this line
2021-10-27 15:10:57 +00:00
const myArray = [];
2021-02-06 04:42:36 +00:00
```
# --solutions--
```js
2021-10-27 15:10:57 +00:00
const myArray = ["The Answer", 42];
2021-02-06 04:42:36 +00:00
```