Skip to content

"Tile Case a Sentence" Challenge does not accept correct solution. #7629

Closed
ManBearPigg opened this Issue · 1 comment

2 participants

@ManBearPigg

Challenge Title Case a Sentence has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) 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 code:

var test = [];
var myArray = [];
function titleCase(str) {
  myArray = str.toLowerCase().split(' ');
  for (i = 0; i < myArray.length; i++) {
   test.push(myArray[i][0].toUpperCase() + myArray[i].substr(1)); 

  }
  return test.join(" ");

}

titleCase("sHoRt AnD sToUt");
@ltegman
Free Code Camp member

Global variables are bad news. Think about what happens if you run that function more than once. Thanks and happy coding!

@ltegman ltegman closed this
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.