freeCodeCamp Challenge Guide: Title Case a Sentence
question: Why are you assigning a value to arrayStr[i]? E.g. arrayStr[i] = arrayStr[i].replace(/[a-z]/, arrayStr[i].substring(0,1).toUpperCase()); I tried using a different variable name, but it...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
How about this version? function titleCase(str) { return str.toLowerCase().split(' ').map(a => a.charAt(0).toUpperCase() + a.substr(1)).join(' '); } Read full topic
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
function titleCase(str) { return str.toLowerCase() .split(' ') .map(word => word[0].toUpperCase() + word.slice(1, word.length)) .join(' '); } Read full topic
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
Solution: The online compiler thing does not like it when I place global variables for some reason? function titleCase(str) { var string=""; //<----buffer variable str=str.toLowerCase().split(' ');...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
MY SOLUTION titleCase(Str) { var oldArr = str.toLowerCase().split(' '); var newArr = []; for (var i in oldArr) { var newWord = oldArr[i][0].toUpperCase() + oldArr[i].slice(1); newArr.push(newWord); }...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
For me this worked out pretty easy! function titleCase(str) { var splitted = str.toLowerCase().split(" "); for (i=0; i<splitted.length; i++) { splitted[i]=splitted[i].charAt(0).toUpperCase() +...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
My solution seems to be valid, why isn’t it working? var string=[]; function titleCase(str) { str=str.toLowerCase().split(' '); for(var a=0;a<=str.length-1;a++) {...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
Here is what I came up with L function titleCase(str) { var arr1 = str.toLowerCase().split(" "); var arr11 = []; for (a = 0; a < arr1.length; a++) { arr11.push(arr1[a][0].toUpperCase() +...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
camperbot: Basic Code Solution: The “Basic” Code Solution doesn’t look basic at all. Am I the only one who found it super confusing? The Intermediate Code Solution was a bit easier to understand… Read...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
var i = 0; function titleCase(str) { var little = str.toLowerCase(); var words = str.split(" "); while (i<words.length){ words.replace( words[i].charAt(0).toUpperCase(),words[i].charAt(0)); i++; }...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
Is there someone who would be able to verify why this is happening? Moderators perhaps? [spoiler]function titleCase(array) { var finalArray = ''; var lowerC = array.toLowerCase().split(' '); for(var i...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
Same here! I wrote the following code which seems to give all the desired outputs, yet I only get a checkmark for the first criteria but a red X for the other three. function titleCase(str) { var arr...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
While my code for this challenge was a little dirty, I was able to finish it. However, although the output is correct, it does not move on to the next challenge. Anyone else have this problem? Read...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
Here is what I was able to come up with for my solution using splice. function titleCase(str) { var lowerCase = str.toLowerCase(); var wordArray = lowerCase.split(" "); var newWord = []; var newLetter...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
Can anyone help me, I have no idea why this doesn’t pass all cases. function titleCase(str) { var arr = str.split(’ ‘); var newStr = ‘’; for (var i = 0; i < arr.length; i++){ var word =...
View ArticlefreeCodeCamp Challenge Guide: Title Case a Sentence
Here’s my solution! function titleCase(str) { var words = str.toLowerCase().split(’ ‘); var upper = []; for (var i = 0; i < words.length; i++) { upper.push(words[i].charAt(0).toUpperCase() +...
View Article