Merge pull request #1408 from bartomiak/master

New snippet - toCharArray
This commit is contained in:
Angelos Chalaris
2020-10-08 15:18:01 +03:00
committed by GitHub

16
snippets/toCharArray.md Normal file
View File

@ -0,0 +1,16 @@
---
title: toCharArray
tags: string,beginner
---
Converts a string to an array of characters.
- Use the spread operator (`...`) to convert the string into an array of characters.
```js
const toCharArray = s => [...s];
```
```js
toCharArray('hello'); // ['h', 'e', 'l', 'l', 'o']
```