| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Change the swapping algorithm to the standard way of swapping using array restructuring.
| if (min > max) { | ||
| const temp = min; | ||
| min = max; | ||
| max = temp; | ||
| } | ||
| if (min > max) [min, max] = [max, min]; | ||
|
|
There was a problem hiding this comment.
Not entirely sure if we should use this as the TOP solution, just because I don't believe it's something introduced to users at the point they're asked to do this exercise (believe it's the lesson they're first introduced to arrays).
Maybe we could add a comment that shows this method as an alternative.
Sorry, something went wrong.
There was a problem hiding this comment.
Done
Sorry, something went wrong.
Update sumAll-solution.js swap algorithm to standard method
Update sumAll-solution.js swap algorithm to standard method
Update sumAll-solution.js swap algorithm to standard method
Update sumAll-solution.js swap algorithm to standard method
Update sumAll-solution.js swap algorithm to standard method
| Back | FazBrowse Home | New Git URL |
Because
I believe this way of swapping the values between variables in JavaScript is better for learners to know about since it is more common and reinforces understanding on array destructuring
This PR
Change the swapping algorithm to the standard way of swapping in JavaScript using array restructuring. Edit: Change for loop condition as well to the standard way
Pull Request Requirements