I have an array of numbers newArr, whose length I use to create an array filled with zeros zeroArr
const newArr = [1,3,5,8,9,3,7,13]
const zeroArr = Array.from(Array(newArr.length), () => 0);
console.log(zeroArr) // [0,0,0,0,0,0,0,0]
Now, I need to replace the last index value 0 to 10 so it should look like this:
const result = [0,0,0,0,0,0,0,10]
How to do this?
zeroArr[zeroArr.length-1] = 10. I would suggest you to read basics of programming.10, but i need to replace the last index in my zeroArr arrayresult = [0,0,0,0,0,0,0,10]like this.