Contenido del Curso
Introduction to JavaScript
4. Declaraciones Condicionales
Introduction to JavaScript
Desafío: Operaciones de Arreglo
Tarea
- Crea un array llamado
myArray
con los datos dados:["Heine", 25, "Bob", 16]
. - Elimina el último elemento,
16
, de la matriz.
- Elimina el último elemento,
- Añade un nuevo elemento con el valor
21
al final de la matriz.
- Añade un nuevo elemento con el valor
- Sustituye el segundo elemento por el valor
27
utilizando indexación. - Imprime el array actualizado en la consola.
La salida debe ser :
1. Use the
2. Use the
3. Access the second element in the array using the index
4. To log the array data to the console, use the
pop()
method to remove an element from the end of an
array. 2. Use the
push()
method to add an element to the end of an
array. 3. Access the second element in the array using the index
1
.
4. To log the array data to the console, use the
console.log()
with the array name.
let myArray = ["Heine", 25, "Bob", 16]; // Step 1
myArray.pop(); // Step 2
myArray.push(21); // Step 3
myArray[1] = 27; // Step 4
console.log(myArray); // Step 5
- Utiliza el método
pop()
para eliminar un elemento del final de un arreglo. - Utiliza el método
push()
para agregar un elemento al final de un arreglo. - Accede al segundo elemento del arreglo utilizando el índice
1
. - Para registrar los datos del arreglo en la consola, usa
console.log()
con el nombre del arreglo.
¿Todo estuvo claro?
Sección 2. Capítulo 8
Contenido del Curso
Introduction to JavaScript
4. Declaraciones Condicionales
Introduction to JavaScript
Desafío: Operaciones de Arreglo
Tarea
- Crea un array llamado
myArray
con los datos dados:["Heine", 25, "Bob", 16]
. - Elimina el último elemento,
16
, de la matriz.
- Elimina el último elemento,
- Añade un nuevo elemento con el valor
21
al final de la matriz.
- Añade un nuevo elemento con el valor
- Sustituye el segundo elemento por el valor
27
utilizando indexación. - Imprime el array actualizado en la consola.
La salida debe ser :
1. Use the
2. Use the
3. Access the second element in the array using the index
4. To log the array data to the console, use the
pop()
method to remove an element from the end of an
array. 2. Use the
push()
method to add an element to the end of an
array. 3. Access the second element in the array using the index
1
.
4. To log the array data to the console, use the
console.log()
with the array name.
let myArray = ["Heine", 25, "Bob", 16]; // Step 1
myArray.pop(); // Step 2
myArray.push(21); // Step 3
myArray[1] = 27; // Step 4
console.log(myArray); // Step 5
- Utiliza el método
pop()
para eliminar un elemento del final de un arreglo. - Utiliza el método
push()
para agregar un elemento al final de un arreglo. - Accede al segundo elemento del arreglo utilizando el índice
1
. - Para registrar los datos del arreglo en la consola, usa
console.log()
con el nombre del arreglo.
¿Todo estuvo claro?
Sección 2. Capítulo 8