Skip to content

Commit 040a452

Browse files
authored
Merge pull request #3 from tejas-2232/master
Updates from original fork
2 parents be9977f + c877dea commit 040a452

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
3+
4+
function sentenceCap(text) {
5+
6+
let wordsarray = text.toLowerCase().split(' ')
7+
8+
let capsArray = wordsarray.map(word => {
9+
return word.replace(word[0], word[0].toUpperCase())
10+
11+
});
12+
13+
return capsArray.join(' ')
14+
15+
}
16+
17+
console.log(sentenceCap("influence"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function sentenceCap(text) {
2+
let wordArray = text.toLowerCase().split(' ')
3+
4+
let capsarray = []
5+
6+
wordArray.forEach(word => {
7+
capsarray.push(word[0].toUpperCase()+ word.slice(1) )
8+
});
9+
10+
return capsarray.join(' ')
11+
12+
}
13+
console.log(sentenceCap("ARTIFICIAL"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
The .map method is used to create a new array with the results
3+
gotten from calling a provided function on every element in the
4+
array on which it is called.
5+
*/
6+
7+
function sentenceCap(text){
8+
9+
let wordsArray = text.toLowerCase().split(' ')
10+
11+
let caparray = wordsArray.map(word => {
12+
return word[0].toUpperCase() + word.slice(1)
13+
14+
});
15+
16+
return caparray.join(' ')
17+
}
18+
19+
console.log(sentenceCap("friends"))
20+
21+
console.log(sentenceCap("PEOPLE"))

0 commit comments

Comments
 (0)