My task involves manipulating arrays. I start with an array of numbers called newArr
. The length of this array is used to create another array filled with zeros, which I named 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, the goal is to change the value at the last index of zeroArr
from 0 to 10
, so it should end up like this:
const result = [0,0,0,0,0,0,0,10]
How can I achieve this modification?