Created
November 9, 2018 00:55
-
-
Save AminBusiness/127c5497ceaca74baf2844341dd40f37 to your computer and use it in GitHub Desktop.
// source https://jsbin.com/gavovuh
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
<script id="jsbin-javascript"> | |
// Challenge 4. Capitalize letters | |
// Returns a string with the first letter of every word capitalized | |
// ex. capitalizeLetters('I love javascript') === 'I love Javascript' | |
function capitalizeLetters(str) | |
{ | |
//Takes a lowercase string and splits it | |
const strArr = str.toLowerCase().split(''); | |
for(let i = 0; i < strArr.length; i++) | |
{ | |
strArr[i] = strArr[i].substring(0,1).toUpperCase() + strArr[i].substring(1); | |
} | |
return strArr.join(' ') | |
////////////// | |
} | |
//Call function | |
const output = capitalizeLetters('i am building myself up from the bottom'); | |
console.log(output); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">// Challenge 4. Capitalize letters | |
// Returns a string with the first letter of every word capitalized | |
// ex. capitalizeLetters('I love javascript') === 'I love Javascript' | |
function capitalizeLetters(str) | |
{ | |
//Takes a lowercase string and splits it | |
const strArr = str.toLowerCase().split(''); | |
for(let i = 0; i < strArr.length; i++) | |
{ | |
strArr[i] = strArr[i].substring(0,1).toUpperCase() + strArr[i].substring(1); | |
} | |
return strArr.join(' ') | |
////////////// | |
} | |
//Call function | |
const output = capitalizeLetters('i am building myself up from the bottom'); | |
console.log(output); | |
</script> |
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
// Challenge 4. Capitalize letters | |
// Returns a string with the first letter of every word capitalized | |
// ex. capitalizeLetters('I love javascript') === 'I love Javascript' | |
function capitalizeLetters(str) | |
{ | |
//Takes a lowercase string and splits it | |
const strArr = str.toLowerCase().split(''); | |
for(let i = 0; i < strArr.length; i++) | |
{ | |
strArr[i] = strArr[i].substring(0,1).toUpperCase() + strArr[i].substring(1); | |
} | |
return strArr.join(' ') | |
////////////// | |
} | |
//Call function | |
const output = capitalizeLetters('i am building myself up from the bottom'); | |
console.log(output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment