Created
December 29, 2019 04:16
-
-
Save risingBirdSong/2b02a40aed2cbf585a9e6877809eca6f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function accum(s:string){ | |
| return s.split('').map((letter, idx)=>{ | |
| let output = letter.repeat(idx + 1).toLowerCase(); | |
| return capitalizeFirstLetter(output); | |
| }).join('-') | |
| } | |
| function capitalizeFirstLetter(string : string) { | |
| return string.charAt(0).toUpperCase() + string.slice(1); | |
| } | |
| // and my favorite solution from another warrior | |
| function accumtwo(s : string) { | |
| return s.split('').map((c, i) => (c.toUpperCase() + c.toLowerCase().repeat(i))).join('-'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment