Skip to content

Title Case A Sentence arrives at the correct result but fails #7610

Closed
Plaskin87 opened this Issue · 1 comment

2 participants

@Plaskin87

Challenge Title Case a Sentence has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My approach is not accepted. I know it's not the nicest solution but it works.
Or is there an error I do not see?

My code:

function titleCase(str) {
 str = str.toLowerCase().split(" ");
    var b ="" ;
  for(i=0;i<str.length;i++){
   for(j=0;j<str[i].length;j++){

    if(str[i][j] === str[i][0]) {
      b += str[i][0].toUpperCase();
      }

    else{
      b +=str[i][j];
      }
   }


    b+= " ";
  }

  return  b;
}
titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");

Bilder-Upload.eu - share DEINE Bilder

@raisedadead
Free Code Camp member

@Plaskin87 You are almost there, the function is returning a string an extra space at the end, that's not visible in console output.

If you are stuck please reach out the JavaScript Chat, for assistance.

Closing as not a site issue.

Thanks and happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.