I'm currently working on a task that involves incrementing the last element in an array using pop() and push(). However, I'm facing an issue where the original values are being retained after I try to increment the popped array.
The objective is to have newArray be equal to _array with the last element increased by 1. For instance, '0,0,7' should become '0,0,8'.
Any guidance or tips in the right direction would be highly valued.
var someArray = [0,0,7];
var incrementLastArrayElement = function(_array) {
var newArray = [];
var popArray = someArray.pop();
newArray = someArray.push(popArray++);
}
console.log(incrementLastArrayElement(someArray));