but instead of getting a modified array of objects, I get an array with only the result of the Math.round which looks like this:
[ 123.34, 3243.12, 122.34]
How do I map the array of objects to get the expected result as described above.
but instead of getting a modified array of objects, I get an array with only the result of the Math.round which looks like this:
[ 123.34, 3243.12, 122.34]
How do I map the array of objects to get the expected result as described above.
Thanks.
javascript
arrays
ecmascript-6
Share
Improve this question
edited Nov 1, 2018 at 9:46Dave Kalu
asked Nov 1, 2018 at 9:43
Dave KaluDave Kalu1,59555 gold badges2222 silver badges4343 bronze badges4
Why your tax values are strings(not numbers)?
– Mohammad Usman
CommentedNov 1, 2018 at 9:45
do you want a new array with new objects or just the same with mutated props?
– Nina Scholz
CommentedNov 1, 2018 at 9:45
@MohammadUsman My bad. That was typo. Thanks.
– Dave Kalu
CommentedNov 1, 2018 at 9:46
@NinaScholz A new array would be preferable.
– Dave Kalu
CommentedNov 1, 2018 at 9:47
You need to return the altered object otherwise it gets overwritten.
Hope this helps
Lloyd
Array.map processes the entry in array and return the processed value. In the attempt, you were only returning the updated tax, however, you will need to return the object. Try following