num -> string -> array -> [sort(), reverse()] -> string -> num

JS is fun!

Code
Diff
  • const descendingOrder = n =>
      +[...''+n].sort().reverse().join``;
  • 1
    function descendingOrder(n){
    
    2
      return Number(String(n).split('').sort(function(a, b){return b-a}).join(''));
    
    3
    }
    
    1+
    const descendingOrder = n =>
    
    2+
      +[...''+n].sort().reverse().join``;