JavaScript for WordPress Forums Vanilla JavaScript Issue with array sorting example

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4938
    Mike Little
    Participant

    (Posting here for completeness, I already tweeted this)
    I spotted an error in your video on Arrays.

    To reverse sort, you need to swap the two parameters passed to the callback function and perform the same subtraction operation.

    See example here https://jsbin.com/xunapa/3/edit?js,console

    Mike

    #4945
    Zac Gordon
    Keymaster

    Thanks so much Mike!

    I just posted an update to the official Code Examples and made a note on the video page.

    Good catch, thank you!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.