First snippet, builder working
This commit is contained in:
23
README.md
23
README.md
@ -1,2 +1,21 @@
|
||||
# 30s of Code
|
||||
A collection of useful Javascript snippets.
|
||||

|
||||
|
||||
# 30 seconds of code
|
||||
> Curated collection of useful Javascript snippets that you can understand in 30 seconds or less.
|
||||
|
||||
- Use <kbd>Ctrl</kbd> + <kbd>F</kbd> or <kbd>command</kbd> + <kbd>F</kbd> to search for a snippet.
|
||||
- Contributions welcome, please read [contribution guide](contributing.md).
|
||||
|
||||
### Sort characters in string (alphabetical)
|
||||
|
||||
Split the string using `split('')`, `sort()` utilizing `localeCompare()`, recombine using `join('')`.
|
||||
|
||||
```js
|
||||
var sortCharactersInString = str =>
|
||||
str.split('').sort( (a,b) => a.localeCompare(b) ).join('');
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
*Icons made by [Smashicons](https://www.flaticon.com/authors/smashicons) from [www.flaticon.com](https://www.flaticon.com/) is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/).*
|
||||
|
||||
|
||||
Reference in New Issue
Block a user