JavaScript - 9

JavaScript - 9: Array Methods

Create an array called numbers. Use array methods to:

  • Add a new number to the end (.push())
  • Remove the first number (.shift())
  • Loop through the array with .forEach() and print each number doubled
✦ JavaScript Editor
▶ Live Output

👀 Show Solution
let numbers = [5, 10, 15, 20];

numbers.push(25);
numbers.shift();

numbers.forEach(num => {
  console.log(num * 2);
});