0 of 8 problems solved • 0%
Use in a course

Changing Arrays

8 exercisesEasy

Arrays can be changed in place, but it matters whether an operation mutates the original or creates a new collection. Methods such as push and pop change an array; spread syntax can make a copy first.

const queue = ["Ari", "Bo"]; queue.push("Cy"); const updatedQueue = [...queue, "Dee"]; console.log(queue); // ["Ari", "Bo", "Cy"] console.log(updatedQueue); // ["Ari", "Bo", "Cy", "Dee"]

The practice covers index updates, adding and removing values, and noticing which reference each operation affects. That distinction prevents accidental changes as programs grow.