From da37e7d585698da5991c76298e8529dcc33b4714 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Tue, 12 Dec 2017 12:55:59 +0200 Subject: [PATCH 1/2] Correct a typo in "slice". --- README.md | 9 +++++++++ snippets/capitalize-first-letter.md | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cf7ebab4e..c0f80715b 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ * [Anagrams of string (with duplicates)](#anagrams-of-string-with-duplicates) * [Average of array of numbers](#average-of-array-of-numbers) * [Capitalize first letter](#capitalize-first-letter) +* [Capitalize first letter.](#capitalize-first-letter.) * [Count occurrences of a value in array](#count-occurrences-of-a-value-in-array) * [Current URL](#current-url) * [Curry](#curry) @@ -75,6 +76,14 @@ var average = arr => ### Capitalize first letter +Use `slice(0,1)` and `toUpperCase()` to capitalize first letter, `slice(1)` to get the rest of the string. + +```js +var capitalize = str => str.slice(0, 1).toUpperCase() + str.slice(1); +``` + +### Capitalize first letter + Use `sice(0,1)` and `toUpperCase()` to capitalize first letter, `slice(1)` to get the rest of the string. ```js diff --git a/snippets/capitalize-first-letter.md b/snippets/capitalize-first-letter.md index 1310e76ed..cfc1415d0 100644 --- a/snippets/capitalize-first-letter.md +++ b/snippets/capitalize-first-letter.md @@ -1,6 +1,6 @@ ### Capitalize first letter -Use `sice(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. ```js var capitalize = str => str.slice(0, 1).toUpperCase() + str.slice(1); From 14a4339c342dce619242501b527c239d79ec0667 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Tue, 12 Dec 2017 12:58:55 +0200 Subject: [PATCH 2/2] Correct stray duplicate snippet. --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index c0f80715b..543dbd858 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ * [Anagrams of string (with duplicates)](#anagrams-of-string-with-duplicates) * [Average of array of numbers](#average-of-array-of-numbers) * [Capitalize first letter](#capitalize-first-letter) -* [Capitalize first letter.](#capitalize-first-letter.) * [Count occurrences of a value in array](#count-occurrences-of-a-value-in-array) * [Current URL](#current-url) * [Curry](#curry) @@ -82,14 +81,6 @@ Use `slice(0,1)` and `toUpperCase()` to capitalize first letter, `slice(1)` to g var capitalize = str => str.slice(0, 1).toUpperCase() + str.slice(1); ``` -### Capitalize first letter - -Use `sice(0,1)` and `toUpperCase()` to capitalize first letter, `slice(1)` to get the rest of the string. - -```js -var capitalize = str => str.slice(0, 1).toUpperCase() + str.slice(1); -``` - ### Count occurrences of a value in array Use `reduce()` to increment a counter each time you encounter the specific value inside the array.