알고리즘 39 - Convert number to reversed array of digits

Q.

Convert number to reversed array of digits
Given a random non-negative number, you have to return the digits of this number within an array in reverse order.

Example:
348597 => [7,9,5,8,4,3]

A)

function digitize(n) {
  return [...n.toString()].map(el => +el).reverse();
}

좋은 웹페이지 즐겨찾기