Algorithm/codewars

Descending Order 답안

Bonita SY 2021. 3. 23. 19:10
728x90
반응형

문제)

www.codewars.com/kata/5467e4d82edf8bbf40000155/train/javascript

 

Codewars: Achieve mastery through challenge

Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential.

www.codewars.com

 

내가 푼 답)

function descendingOrder(n){
  var str_n = String(n).split('').sort((a, b) => Number(b)-Number(a))
  return Number(str_n.join(''));
}

 

테스트 결과)

 

마음에 드는 다른 사람 코드)

728x90
반응형

'Algorithm > codewars' 카테고리의 다른 글

Exes and Ohs 답안  (0) 2021.03.23
You're a square! 답안  (0) 2021.03.23
Convert string to camel case 답안  (0) 2021.03.23
Categorize New Member 답안  (0) 2021.03.23
Decode the Morse code 답안  (0) 2021.03.23