* chore(i8n,learn): processed translations * fix: remove extra space Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com> Co-authored-by: Crowdin Bot <support+bot@crowdin.com> Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>
1.4 KiB
1.4 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56bbb991ad1ed5201cd392cb | Manipula arreglos con push() | 1 | https://scrimba.com/c/cnqmVtJ | 18237 | manipulate-arrays-with-push |
--description--
Una forma fácil de añadir datos al final de un arreglo es a través de la función push()
.
.push()
toma uno o más parámetros y los "empuja" al final del arreglo.
Ejemplos:
var arr1 = [1,2,3];
arr1.push(4);
var arr2 = ["Stimpson", "J", "cat"];
arr2.push(["happy", "joy"]);
arr1
ahora tiene el valor [1, 2, 3, 4]
y arr2
tiene el valor ["Stimpson", "J", "cat", ["happy", "joy"]]
.
--instructions--
Empuja ["dog", 3]
al final de la variable myArray
.
--hints--
myArray
debe ser igual a [["John", 23], ["cat", 2], ["dog", 3]]
.
assert(
(function (d) {
if (
d[2] != undefined &&
d[0][0] == 'John' &&
d[0][1] === 23 &&
d[2][0] == 'dog' &&
d[2][1] === 3 &&
d[2].length == 2
) {
return true;
} else {
return false;
}
})(myArray)
);
--seed--
--after-user-code--
(function(z){return 'myArray = ' + JSON.stringify(z);})(myArray);
--seed-contents--
// Setup
var myArray = [["John", 23], ["cat", 2]];
// Only change code below this line
--solutions--
var myArray = [["John", 23], ["cat", 2]];
myArray.push(["dog",3]);