-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from tejas-2232/master
Updates from original fork
- Loading branch information
Showing
3 changed files
with
51 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,17 @@ | ||
|
||
|
||
|
||
function sentenceCap(text) { | ||
|
||
let wordsarray = text.toLowerCase().split(' ') | ||
|
||
let capsArray = wordsarray.map(word => { | ||
return word.replace(word[0], word[0].toUpperCase()) | ||
|
||
}); | ||
|
||
return capsArray.join(' ') | ||
|
||
} | ||
|
||
console.log(sentenceCap("influence")) |
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,13 @@ | ||
function sentenceCap(text) { | ||
let wordArray = text.toLowerCase().split(' ') | ||
|
||
let capsarray = [] | ||
|
||
wordArray.forEach(word => { | ||
capsarray.push(word[0].toUpperCase()+ word.slice(1) ) | ||
}); | ||
|
||
return capsarray.join(' ') | ||
|
||
} | ||
console.log(sentenceCap("ARTIFICIAL")) |
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,21 @@ | ||
/* | ||
The .map method is used to create a new array with the results | ||
gotten from calling a provided function on every element in the | ||
array on which it is called. | ||
*/ | ||
|
||
function sentenceCap(text){ | ||
|
||
let wordsArray = text.toLowerCase().split(' ') | ||
|
||
let caparray = wordsArray.map(word => { | ||
return word[0].toUpperCase() + word.slice(1) | ||
|
||
}); | ||
|
||
return caparray.join(' ') | ||
} | ||
|
||
console.log(sentenceCap("friends")) | ||
|
||
console.log(sentenceCap("PEOPLE")) |