# Basicc Algorithm Scripting: Title Case a Sentence

Here is the link of this challenge:https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/title-case-a-sentence

my result is the same as the answer but why this hapeen. Anyone Explain for me please.

here is my code:

``````function titleCase(str) {
// let arr = [];
str=str.toLowerCase();
str=" "+str+" ";
let rel="";
//  let a=/a/i,
// the=/the/i;
for (let i = 0 , l = str.length, se="" ; i < l ; i ++) {
if (str[i]==" ") {
//arr.push(se);
//       console.log(se);
// console.log(se);
if ((se=="a" ) || (se=="The")) {
se = se.toUpperCase();
//  console.log(se);
}
rel+=se+" ";
se="";

if (i!==l-1) se += str[i+1].toUpperCase();
continue;
}
if (str[i-1]!==" ")se += str[i].toLowerCase();

}
return rel.slice(1,rel.length-1);
//return rel-" ";
}

console.log(titleCase("I'm a little tea pot the"));

let a='f';
//console.log(ASCI);

``````

try this console.log:
`console.log("-->" + titleCase("I'm a little tea pot" + "<--"));`
do you see the difference with the required output?

yes, absolutly, sir. It is completely different

one single character is enough to make strings not match

can you see it?

1 Like

confront with

``````console.log("-->" + "I'm A Little Tea Pot" + "<--")`
``````
1 Like

got it, bro. Thank you!!!

do me a favour and stop referring about me as male

1 Like

excuse me, what is your gender?

this is not doing what you think
1- toUpperCase() returns a new value, it doesnâ€™t change `se`
2- `se==a` and `se==the` always return false as you canâ€™t compare a regex and a string like that

ok, got it. I will fixed it. Thank you again