Created
March 6, 2019 06:43
-
-
Save hassansw/0f608b9d5a43da6072fc4628d4cfc407 to your computer and use it in GitHub Desktop.
Order number to descending or ascending order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function descendingOrder(n){ | |
const newArr = (n).toString(10).split("").map(Number); | |
return parseInt(newArr.sort(function (a, b) { return b - a }).join("")) // replace (b-a) to (a-b) for ascending order | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment