I am trying to update the back of an array WITHOUT using the push() function, so I decided to use the splice() function and pass -1, and 0, and then the value so that it would update my array at the last index. I am then trying to return the length of the updated array, which should be 5.
function push(array, value) {
var upDatedArray = array.splice(-1, 0, value);
var lengthArray = upDatedArray.length;
return lengthArray;
}
console.log (
push([1, 2, 3, 4, 5], 6)
);
What am I doing wrong here? Because it keeps returning 0, rather than the desired '5' length that I am looking for?