Why did Codecademy choose to use `.push` instead of `.prepend`

Seeing as .push is a method which allows us to add items to the end of an array, why did they not choose .prepend? Link to Challenges

// Write your code here:
const convertToBaby = arr => {
  const babyArray = [];
  for (let i = 0; i < arr.length; i++)
  {
    babyArray.push('baby ' + arr[i]);
  }
  return babyArray
}

const animals = ['panda', 'turtle', 'giraffe', 'hippo', 'sloth', 'human'];

console.log(convertToBaby(animals)) 


the built-in prepend method seems to be for nodes (when interacting with the DOM). At least, I couldn’t find an array prepend method, what did you find?

looking at this stackoverflow question:

javascript - Most efficient way to prepend a value to an array - Stack Overflow

seems .unshift is decent.

Arrays are generally better add appending data then prepending data.

2 Likes