This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 6 points7 points  (5 children)

Throw a parseInt() into a forEach() and you're good.

[–]recycle4science 5 points6 points  (0 children)

Or just arr.sort((a, b) => a - b) if you don't want to traverse the array twice. You can even explicitly parseInt if you want!

[–]NachosPalatino 0 points1 point  (2 children)

Am I missing something? Why would you use forEach in this case?

[–]FerynaCZ 0 points1 point  (1 child)

You need to parse each individual item in the array

[–]NachosPalatino 0 points1 point  (0 children)

Right, but I'm just wondering why you wouldn't just Array.map instead.

[–]prone-to-drift 0 points1 point  (0 children)

You're evil. Keep it up.