updating function to use spread operator to make it more ES6ish
This commit is contained in:
@ -4,6 +4,6 @@ Convert the number to a string, use `split()` to convert build an array.
|
|||||||
Use `Array.map()` and `parseInt()` to transform each value to an integer.
|
Use `Array.map()` and `parseInt()` to transform each value to an integer.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const digitize = n => (''+n).split('').map(i => parseInt(i));
|
const digitize = n => [...''+n].map(i => parseInt(i));
|
||||||
// digitize(2334) -> [2, 3, 3, 4]
|
// digitize(2334) -> [2, 3, 3, 4]
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user