Files
freeCodeCamp/curriculum/challenges/espanol/02-javascript-algorithms-and-data-structures/basic-javascript/modify-array-data-with-indexes.md
camperbot 0432ec995f chore(i18n,learn): processed translations (#41387)
* 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>
2021-03-07 08:15:14 -08:00

1.5 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
cf1111c1c11feddfaeb8bdef Modifica los datos de un arreglo con índices 1 https://scrimba.com/c/czQM4A8 18241 modify-array-data-with-indexes

--description--

A diferencia de las cadenas, las entradas de los arreglos son mutables y pueden cambiarse libremente.

Ejemplo

var ourArray = [50,40,30];
ourArray[0] = 15;

ourArray ahora tiene el valor [15, 40, 30].

Nota: No debe haber espacios entre el nombre del arreglo y los corchetes, como array [0]. Aunque JavaScript pueda procesar esto correctamente, puedes confundir a otros programadores al leer tu código.

--instructions--

Modifica los datos almacenados en el índice 0 de myArray a un valor de 45.

--hints--

myArray ahora debe ser [45,64,99].

assert(
  (function () {
    if (
      typeof myArray != 'undefined' &&
      myArray[0] == 45 &&
      myArray[1] == 64 &&
      myArray[2] == 99
    ) {
      return true;
    } else {
      return false;
    }
  })()
);

Debes usar el índice correcto para modificar el valor en myArray.

assert(
  (function () {
    if (code.match(/myArray\[0\]\s*=\s*/g)) {
      return true;
    } else {
      return false;
    }
  })()
);

--seed--

--after-user-code--

if(typeof myArray !== "undefined"){(function(){return myArray;})();}

--seed-contents--

// Setup
var myArray = [18,64,99];

// Only change code below this line

--solutions--

var myArray = [18,64,99];
myArray[0] = 45;