Skip to content

Commit

Permalink
Merge pull request #3 from tejas-2232/master
Browse files Browse the repository at this point in the history
Updates from original fork
  • Loading branch information
rachleona authored Oct 2, 2020
2 parents be9977f + c877dea commit 040a452
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Senten_capitaliztion_4/sentence_cap_Map_nd_replace.js
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"))
13 changes: 13 additions & 0 deletions Senten_capitaliztion_4/sentence_cap_forEach.js
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"))
21 changes: 21 additions & 0 deletions Senten_capitaliztion_4/sentence_cap_map_slice.js
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"))

0 comments on commit 040a452

Please sign in to comment.