Basic Algorithm Scripting: Title Case a Sentence**

Is there another way to do this easier.

function titleCase(str) {
let newArr=[];
let slicedArr=[];
let lowCaStr=str.toLowerCase();                 
let splitStr=lowCaStr.split(" ");


      for (let i=0;i<splitStr.length;i++){          
           let firstLetter=splitStr[i].charAt(0);
           let capLetter=firstLetter.toUpperCase()


        for (let i=0;i<splitStr.length;i++){          
           let slicedStr=splitStr[i].slice(1);         

let newArray =, i) => e + slicedArr[i]);
console.log(newArray.join(" "))
return newArray.join(" ")

titleCase("sHoRt AnD sToUt");

You can look at the Guide solutions to see other ways of completing this challenge.

1 Like