Created
June 23, 2020 07:36
-
-
Save robinpokorny/140d3a4789459039833d1db280eb2e1d to your computer and use it in GitHub Desktop.
For vs map/filter/reduce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const words = ["hello", " ", "world"]; | |
for (let i = 0; i <= words.length; i++) { | |
const word = words[i]; | |
if (word.length <= 0) continue; | |
words[i] = uppercaseFirstLetter(word.trim()); | |
} | |
const titlecasedWords = words | |
.filter(isNotEmpty) | |
.map(trim) | |
.map(uppercaseFirstLetter); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment