Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Challenge: Perform Array Operations | Variables and Data Types in JavaScript
Introduction to JavaScript
course content

Contenido del Curso

Introduction to JavaScript

Introduction to JavaScript

1. JavaScript Fundamentals
2. Variables and Data Types in JavaScript
3. Performing Operations in JavaScript
4. Controlling Program Flow with Conditional Statements
5. Looping Through Data in JavaScript
6. Functions in JavaScript

book
Challenge: Perform Array Operations

Task

  1. Create an array named myArray with the given data: ["Heine", 25, "Bob", 16].
  2. Remove the last element, 16, from the array.
  3. Add a new element with the value 21 to the end of the array.
  4. Replace the second element with the value 27 using indexing.
  5. Print the updated array to the console.
12345
let ___ = ["Heine", 25, "Bob", 16]; myArray.___(); myArray.___(21); myArray[___] = 27; console.log(___);
copy

The output should be :

  1. 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.
12345
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
copy

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 8
We're sorry to hear that something went wrong. What happened?
some-alt