Hello,
I have wrote this code and not sure why its not working. I am probably totally off but here is my code that I have attempted…any input appreciated…
function titleCase(str) {
var allensArray = str.toLowerCase().split(" ");
for (i = 0; i < allensArray.length; i++){
allensArray[i].charAt(0).toUpperCase();
}
var newArray = allensArray.join(" ");
return newArray;
}
titleCase(“I’m a little tea pot”);
Quickz
April 29, 2017, 1:40pm
2
The line below for loop is not getting assigned to anything.
so i did this,
and still not working…doh
function titleCase(str) {
var allensArray = str.toLowerCase().split(" ");
for (i = 0; i < allensArray.length; i++){
var newArray = allensArray[i].charAt(0).toUpperCase();
var latestArray = newArray.join(" ");
}
return latestArray;
}
titleCase(“sHoRt AnD sToUT”);
Quickz
April 29, 2017, 2:02pm
4
Only line below for loop needs changing. That piece has to be assigned to allensArray[i] and concatenated with the remainder of the word.
You might wanna use this to get the remaining piece.
https://www.w3schools.com/jsref/jsref_substr.asp
Figured it out! thanks @Quickz