📅  最后修改于: 2022-03-11 15:04:07.799000             🧑  作者: Mango
//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