Last active
October 23, 2019 06:51
-
-
Save santhosh17s/b4c7c56f1f3e8dc0ef75ddf32707b762 to your computer and use it in GitHub Desktop.
Combination of greater number from random 10 digits.
This file contains hidden or 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
/* | |
Take 10 random number. From that to get combination of greater number. | |
Example to take number - 4132 And result to be 4321. | |
*/ | |
let randomNumber = 3159705179; | |
let greaterNbr; | |
let randomNumberArray = (''+randomNumber).split(''); | |
randomNumberArray.sort( (a, b) => b - a ); | |
greaterNbr = randomNumberArray.join(''); | |
console.log(greaterNbr); //9977553110 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment