Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gives the correct result, but doesn't give a checkmark #3366

Closed
Deeevo opened this issue Sep 19, 2015 · 9 comments
Closed

Gives the correct result, but doesn't give a checkmark #3366

Deeevo opened this issue Sep 19, 2015 · 9 comments
Assignees

Comments

@Deeevo
Copy link

Deeevo commented Sep 19, 2015

Challenge Bonfire: Title Case a Sentence has an issue.
User Agent is: Mozilla/5.0 (Windows NT 5.1; rv:40.0) Gecko/20100101 Firefox/40.0.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

function titleCase(str) {
  str = str.toLowerCase().replace(/((?=\b)([a-z])(?=[a-z]|'))|(\b[a]?)/g, function(firstLetter){
  return firstLetter.toUpperCase();
  });
  return str;
}

titleCase("I'm a little tea pot");

This code returns what the challenge asks for, yet it doesn't give a green checkmark for it.

@bugron bugron self-assigned this Sep 19, 2015
@bugron bugron added the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label Sep 19, 2015
@bugron
Copy link
Contributor

bugron commented Sep 19, 2015

@Deeevo thanks for pointing this out! I've submitted a PR.


Please review the Guidelines for Contributing, thank you!.


@eldios
Copy link

eldios commented Sep 22, 2015

+1 :)

@anrddh anrddh removed the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label Sep 24, 2015
@Deeevo
Copy link
Author

Deeevo commented Sep 26, 2015

This issue hasn't been resolved yet. I'm getting the same result and it's still not passing...

@anrddh
Copy link
Member

anrddh commented Sep 26, 2015

Deploying the staging code to production happens once every week or so.

@jero930
Copy link

jero930 commented Oct 28, 2015

Hi,

I have the same issue.
Here is my code

text="";
function titleCase(str) {
array = str.split(" ");
for(i=0; i<array.length; i++){
text += array[i].charAt(0).toUpperCase()
+ array[i].substr(1,array[i].length-1).toLowerCase()
+ " ";
}
return text.trim();
}

titleCase("sHoRt AnD sToUt");

@ltegman
Copy link
Member

ltegman commented Oct 28, 2015

@jero930 Your code is failing the tests because you're using a global variable text in your function. It looks like it works because the first time you run the function it works as expected, but any time after that the function won't work as expected because the text variable is not empty. You should be initializing your variables in the function itself with a var keyword in front of it to avoid this problem.

Thanks and happy coding!

@jero930
Copy link

jero930 commented Oct 28, 2015

Hi Logan,

Thanks for the help!

Best,
Jerome

On Wed, Oct 28, 2015 at 9:38 AM, Carley Faircloth notifications@github.com
wrote:

I still can't sign in, when it seems me my passwords it's sent by a
outlook account without the link active and I can't cut it, idk I'm tired
of getting nowhere with this

Sent by Outlook for Android

From: Logan Tegman

Sent: Tuesday, October 27, 8:32 PM

Subject: Re: [FreeCodeCamp] Gives the correct result, but doesn't give a
checkmark (#3366)

To: FreeCodeCamp/FreeCodeCamp

@jero930 Your code is failing the tests because you're using a global
variable text in your function. It looks like it works because the first
time you run the function it works as expected, but any time after that the
function won't work as expected because the text variable is not empty. You
should be initializing your variables in the function itself with a var
keyword in front of it to avoid this problem.

Thanks and happy coding!

Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#3366 (comment)
.

@fedehc
Copy link

fedehc commented Oct 30, 2015

Well, I have a similar problem too.

My code:

function titleCase(str)
{
  str = str.toLowerCase().replace(/\b\S/g, function (m) {return m.toUpperCase();});
  str = str.replace(/'\S/g, function (n) {return n.toLowerCase();});
  return str;
}

titleCase("I'm a little tea pot");

I get the correct string, but I don't get the green checkmark. :(

@ltegman
Copy link
Member

ltegman commented Oct 31, 2015

Looks like the PR that fixed this issue has been overwritten. I'm making a new PR for this now.

@ltegman ltegman reopened this Oct 31, 2015
@ltegman ltegman assigned ltegman and unassigned bugron Oct 31, 2015
ltegman added a commit to ltegman/FreeCodeCamp that referenced this issue Oct 31, 2015
@dcsan dcsan added status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. and removed confirmed labels Oct 31, 2015
@bugron bugron removed the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label Oct 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants