I am attempting to push one index of my array into it's own array. I am attempting this by using the forEach() method.
I have an array that is nested inside of an array revData that has multiple indexes inside of its array. I expecting to push out only index 5 of the array into its own array so I can graph the data.
At the moment using doing my forEach method, my newArr only has the first index 5 five times.
My expected out come is to have the newArr have 3 results coming from the values of index 5 from revData such as :
newArr = [ 24343.1 , 44321.0, 43242.8 ]
Here is an example of my code :
let revData = [
[1, 1, 1, "22", "online stores", 24343.1 ],
[2, 2 ,2, "13", "retail stores", 44321.0],
[ 3, 3, 3, "7", "walk ins", 43242.8]
]
const newArr = []
revData[0].forEach(function () {
newArr.push(revData[0][5])
})
console.log(newArr)