Freecodecamp: Test fails on "Only change the first line"

Created on 3 Feb 2017  路  23Comments  路  Source: freeCodeCamp/freeCodeCamp

Challenge subtract-one-number-from-another-with-javascript has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.
This fails due to the difference in lines even if code has not been changed. It also fails when changing 0 to 33.

var difference = 45 - 0;



screen shot 2017-02-03 at 1 00 14 am
screen shot 2017-02-03 at 12 59 49 am

help wanted

All 23 comments

10633 Previously discussed here.

I can reproduce this one. Related file: seed/challenges/02-javascript-algorithms-and-data-structures/basic-javascript.json

I'll take this one!

Can someone help me understand the purpose of the "Only change first line" test? I don't see a use for it.
"assert((code).match(/difference/g).length === 1,'message: Only change the first line');"

So I took it out. And everything works fine now.
screen shot 2017-02-03 at 1 51 44 am

@dnahol The previous challenge, Add Two Numbers, doesn't have a test case like this one. These two challenges look like very similar. I think it's ok.

Thanks @hisener. That's a good point. I will remove it then.

This issue stems probably because the "solution" in the .json file is included in the code the regex checks (see similar discussion https://github.com/freeCodeCamp/freeCodeCamp/pull/11987#discussion_r92950694). The code is to check that you don't just create another variable difference and assign it to 12. So I think it's necessary. Just need to either remove the solution or change the test to check for two instances.

@erictleung Thank you! That makes sense!

@erictleung It makes sense, then let's make it 3 and add this test case to addition, multiplication and division challenges.

@dnahol I can take this if you don't?

@hisener I got it. But maybe you want to take the others you mentioned?

@dnahol I think all changes make more sense into a single commit.

This still is a problem, as of 31 March 2017

This is still a problem!

This is still a problem on May 24. Deleting the blank first line so that the code is on the first line doesn't solve it either.

There are different bugs in the live and beta version of the site. On the live site, when you change a line other than the first one and don't reference the "difference" variable, "Only change the first line" is still green. If you do use the "difference" variable in a different line in the program then the checkpoints work properly.

screen shot 2017-11-06 at 2 50 31 pm
screen shot 2017-11-06 at 2 50 15 pm

On the beta version, if you only subtract one number from 45 and it's the wrong number, "Only subtract one number from 45" is still red.

screen shot 2017-11-06 at 2 50 52 pm

I would like to work on the bug on the beta site. The bug has to do with the following test:

assert(/var\\s*difference\\s*=\\s*45\\s*-\\s*33;?/.test(code),'message: Only subtract one number from 45.');

The test only allows for 33 to be subtracted from 45, but the test is just supposed to be checking that one number is subtracted from 45. The actual number shouldn't matter since the value of the difference variable is already being checked in the other test

@rcohane are you still interested in fixing this?

@raisedadead Yes, I changed the test to:

"assert(/var\\s*difference\\s*=\\s*45\\s*-\\s*[0-9]*;{1}/.test(code),'message: Only subtract one number from 45.');".

Now it checks that only one number is subtracted from 45 and that number doesn't have to be 33. I'll create a pull request.

@rcohane awseome. thanks for working on this.

image
i am still getting an issue. what's the solution for this problem?

@theshivanjali please try removing the space between the 33 and semicolon

Hi @theshivanjali

Thanks for reporting this issue.

Please use the Chat Rooms or try looking through our forum for help with a specific challenge and any coding assistance.

IMPORTANT:
Please NOTE that this tracker is for reporting bugs and enhancements to freeCodeCamp's code base only.

Happy Coding!

Was this page helpful?
0 / 5 - 0 ratings