1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-18 12:02:53 +02:00

Add "camel-case" challenge

This commit is contained in:
Divlo
2020-07-05 20:09:17 +02:00
parent 7c9c59e5b1
commit 3d4aa20915
6 changed files with 51 additions and 1 deletions

View File

View File

@ -0,0 +1,4 @@
# typescript-camelcase - camel-case
Programming language : TypeScript
Created by [@Divlo](https://github.com/Divlo) at 5 July 2020.

View File

@ -0,0 +1,14 @@
function solution (string: string) {
return string.length === 0
? ''
: string
.trim()
.split(' ')
.map((word, index) => {
if (index === 0) return word
return word[0].toUpperCase() + word.slice(1)
})
.join('')
}
export default solution