DEV Community

Discussion on: To Mutate, Or Not To Mutate? JavaScript Array Methods Cheat Sheet

Collapse
 
jamiemccarville profile image
Jamie McCarville 🇨🇦

Great post Annie!

I just have one suggestion that could make the .sort() explanation a little clearer. You said just before the last code snippet:

"If you really want to sort the numbers in an order that makes human sense, you can pass in a compare function as an argument in the .sort() method:"

You then show the compare function in the snippet. I think it would be great to have a short explanation of how the compare function works, what it does to sort the numbers. I read the article that you linked to and it has a really great three bullet explanation. I think adding something similar just after the code snippet would help to make it just a little bit more clear.

Collapse
 
liaowow profile image
Annie Liao

This is spot-on, Jamie. Just added the explanation. Thanks so much for helping me perfect this post!