Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Pushing Elements to an Array | Exploring Arrays
Introduction to JavaScript

Swipe to show menu

book
Challenge: Pushing Elements to an Array

Task

Swipe to start coding

  • You have an array named shoppingList that contains the following three elements: Milk, Eggs, and Bread.
  • Use the push() method to add the following two elements to the array: Butter, Cheese. (Please add these elements in the required order)
  • Use a console.log() statement to output the entire array in the format: After: [element1, element2, ...].

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 5

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

book
Challenge: Pushing Elements to an Array

Task

Swipe to start coding

  • You have an array named shoppingList that contains the following three elements: Milk, Eggs, and Bread.
  • Use the push() method to add the following two elements to the array: Butter, Cheese. (Please add these elements in the required order)
  • Use a console.log() statement to output the entire array in the format: After: [element1, element2, ...].

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 5
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt