Each newdata[x][0]]
looks like this -> [95, 152, 174, 197, 261]
but when I do newgooddata.push([newdata[x][0]])
twice (x=0 and 1)
I get
I want it to be:
I seem to be adding them wrong. Some help , with an explanation?
Each newdata[x][0]]
looks like this -> [95, 152, 174, 197, 261]
but when I do newgooddata.push([newdata[x][0]])
twice (x=0 and 1)
I get
I want it to be:
I seem to be adding them wrong. Some help , with an explanation?
Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Jul 23, 2013 at 23:48 mike628mike628 49.4k19 gold badges45 silver badges57 bronze badges 1- 4 mdn array docs – aaronman Commented Jul 23, 2013 at 23:51
1 Answer
Reset to default 5You are putting newdata[x][0]
into an array before pushing.
newgooddata.push([newdata[x][0]]) // bad
newgooddata.push(newdata[x][0]) // good
The extra []
around newdata[x][0]
creates a new array containing one element: newdata[x][0]
.