//Method 2
//rearrange the digits to create the highest possible number
function descendingOrder(n){
let reversed = n.toString().split("").sort((a, b) => b - a).join('');
return parseInt(reversed) * Math.sign(n);
}
console.log(descendingOrder(463)); // result: 643
console.log(descendingOrder(223744)); // result: 744322
//Method 1
//rearrange the digits to create the highest possible number
function descendingOrder(n){
return parseInt(String(n).split('').sort().reverse().join(''));
}
console.log(descendingOrder(15)); // result: 51
console.log(descendingOrder(22314)); // result: 43221