So say we have a number -- 123456 for simplicity sake. I needed a function that would take that as input and return 654321, or say 53283940, same would return 98543320.
I have something seems to work I'm just not sure if it's done with best practice, it seems like it can be re-factored into something cleaner. Here is what I have, any help? I'm new trying to improve, thank you.
function descendingOrder(a){
let b = Array.from(a.toString()).map(Number); // map int into array
let stringResult = b.sort().reverse().join(""); // sort in ascending, then reverse & join
let intResult = ~~stringResult; // double bitwise operator to turn str to int
return intResult; // return final int
}