updated changes
This commit is contained in:
@ -5,12 +5,9 @@ use `Array.reverse()` to return the array in the same order as the number.
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const num2array = (n) =>{
|
const num2array = (n) =>{
|
||||||
let arr = [];
|
return (''+n).split('').map((i) =>{
|
||||||
while (n>0) {
|
return parseInt(i);
|
||||||
arr.push(n%10);
|
})
|
||||||
n = parseInt(n/10);
|
|
||||||
}
|
|
||||||
return arr.reverse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// num2array(2334) -> [2, 3, 3, 4]
|
// num2array(2334) -> [2, 3, 3, 4]
|
||||||
|
|||||||
Reference in New Issue
Block a user