Build README

This commit is contained in:
Angelos Chalaris
2017-12-12 15:38:34 +02:00
parent 2964ac486b
commit c83394b44a
2 changed files with 16 additions and 9 deletions

View File

@ -10,8 +10,8 @@
* [Anagrams of string (with duplicates)](#anagrams-of-string-with-duplicates) * [Anagrams of string (with duplicates)](#anagrams-of-string-with-duplicates)
* [Average of array of numbers](#average-of-array-of-numbers) * [Average of array of numbers](#average-of-array-of-numbers)
* [Capitalize first letter](#capitalize-first-letter)
* [Capitalize first letter of every word](#capitalize-first-letter-of-every-word) * [Capitalize first letter of every word](#capitalize-first-letter-of-every-word)
* [Capitalize first letter](#capitalize-first-letter)
* [Count occurrences of a value in array](#count-occurrences-of-a-value-in-array) * [Count occurrences of a value in array](#count-occurrences-of-a-value-in-array)
* [Current URL](#current-url) * [Current URL](#current-url)
* [Curry](#curry) * [Curry](#curry)
@ -75,6 +75,14 @@ const average = arr =>
arr.reduce( (acc , val) => acc + val, 0) / arr.length; arr.reduce( (acc , val) => acc + val, 0) / arr.length;
``` ```
### Capitalize first letter of every word
Use `replace()` to match the first character of each word and `toUpperCase()` to capitalize it.
```js
var capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
```
### Capitalize first letter ### Capitalize first letter
Use `slice(0,1)` and `toUpperCase()` to capitalize first letter, `slice(1)` to get the rest of the string. Use `slice(0,1)` and `toUpperCase()` to capitalize first letter, `slice(1)` to get the rest of the string.
@ -83,16 +91,8 @@ Use `slice(0,1)` and `toUpperCase()` to capitalize first letter, `slice(1)` to g
const capitalize = str => str.slice(0, 1).toUpperCase() + str.slice(1); const capitalize = str => str.slice(0, 1).toUpperCase() + str.slice(1);
``` ```
### Capitalize first letter of every word
Use `replace()` to match the first character of each word and `toUpperCase()` to capitalize it.
```js
var capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
```
### Count occurrences of a value in array ### Count occurrences of a value in array
Use `reduce()` to increment a counter each time you encounter the specific value inside the array. Use `reduce()` to increment a counter each time you encounter the specific value inside the array.
```js ```js

View File

@ -0,0 +1,7 @@
### Capitalize first letter of every word
Use `replace()` to match the first character of each word and `toUpperCase()` to capitalize it.
```js
var capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
```