-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62c83b3
commit 802f25f
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// https://www.codewars.com/kata/the-hashtag-generator/ | ||
// The marketing team is spending way too much time typing in hashtags. | ||
// Let's help them with out own Hashtag Generator! | ||
|
||
// Here's the deal: | ||
|
||
// - It must start with a hashtag (#). | ||
// - All words must have their first letter capitalized. | ||
// - If the final result is longer than 140 chars it must return false. | ||
// - If the input or the result is an empty string it must return false. | ||
function generateHashtag (str) { | ||
const output = str.trim().length > 0 && | ||
'#'+str.split(' ').map(word => word && word[0].toUpperCase() + word.slice(1)).join(''); | ||
return output.length <= 140 && output; | ||
} |