-1

How do I add a new object to an array and how do I return the update array with the new object added to the end? this is the data I have!

newCandy = { candy:"Skittles" , inStock:200, 10, };

and this is the function

function addNewcandy(inventory,newCandy)

1 Answers1

0

Like this

const newArray = [...oldArray, newObject]
Nikita Mazur
  • 1,602
  • 1
  • 5
  • 14