Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- TABLESPACE
- java api
- isSquare
- codewar
- manifest.json
- DB2
- react hook
- useEffect
- codewars
- JDBC
- type
- react
- TypeScript
- Debug
- custom hook
- IBM
- descendingOrder
Archives
- Today
- Total
taesik
Write Number in Expanded Form 본문
function expandedForm(num) {
return String(num)
.split("")
.map((num, index, arr) => num + "0".repeat(arr.length - index -1 ))
.filter((num) => Number(num) != 0)
.join(" + ")
}
const expandedForm = n => n.toString()
.split("")
.reverse()
.map( (a, i) => a * Math.pow(10, i))
.filter(a => a > 0)
.reverse()
.join(" + ");'functions and trick > typescript_javascript' 카테고리의 다른 글
| Sum of numbers from 0 to N (0) | 2022.01.25 |
|---|---|
| how many times father see kid's falling and bouncing ball (0) | 2022.01.25 |
| alpabet war (0) | 2022.01.25 |
| isAscending (0) | 2022.01.25 |
| diamond with * (0) | 2022.01.24 |