My code for this challenge works fine. However, I can’t pass the challenge when I run tests. Here is my code:
function titleCase(str) {
str=str.toLowerCase();
var array=str.split(’ ');
for(var i=0;i<array.length;++i){
array[i]=array[i].replace(array[i].charAt(0),array[i].charAt(0).toUpperCase());