Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing compare function in test #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

patgarcia
Copy link

According to MDN docs on Array.prototype.sort

The default sort order is ascending, built upon converting the elements into strings

[100,2].sort()
// [100, 2]

So we would need the compare function to sort numbers properly

[100,2].sort((a,b) => a - b)
// [2, 100]

According to MDN docs [on Array.prototype.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
>The default sort order is ascending, built upon converting the elements into strings
```javascript
[100,2].sort()
// [100, 2]```
So we would need the compare function to sort numbers properly
```javascript
[100,2].sort((a,b) => a - b)
// [2, 100]```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant