Freecodecamp: Remainder challenge needs numbers directly used in modulo

Created on 11 May 2016  Â·  11Comments  Â·  Source: freeCodeCamp/freeCodeCamp

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

My code:


// Only change code below this line
var a=11;
var b=3;
var remainder;
var remainder=a % b;
first timers only help wanted

Most helpful comment

@ashekgo thanks for the issue. Your answer will give the correct answer, but because our site is directed to beginner coders, this challenge is more simple than you think. The challenge simply wants you to take the remainder directly remainder = 11 % 3.

cc/ @FreeCodeCamp/issue-moderators worth changing? I was thinking we modify the You should use the % operator test to just look for the modulo character. Then we add another test that uses the current test looking for the modolo character to look for the use of two numbers directly with the modulo symbol.

/\d+\s*%\s*\d+/.test(code)

All 11 comments

@ashekgo thanks for the issue. Your answer will give the correct answer, but because our site is directed to beginner coders, this challenge is more simple than you think. The challenge simply wants you to take the remainder directly remainder = 11 % 3.

cc/ @FreeCodeCamp/issue-moderators worth changing? I was thinking we modify the You should use the % operator test to just look for the modulo character. Then we add another test that uses the current test looking for the modolo character to look for the use of two numbers directly with the modulo symbol.

/\d+\s*%\s*\d+/.test(code)

@erictleung Or we can only check for the use of modulo and the value of the remainder variable so that users can complete the challenge either by using variables or using numbers.

@pranayberry that sounds good to me. Just looking for the modulo character so something like this might help.

...
"assert(/%/.test(code), 'message: You should use the <code>%</code> operator');"
...

This line needs to be changed.

@erictleung I used the following test locally.
assert(/.*%.*/.test(code), 'message: You should use the <code>%</code> operator');
Is it any different from yours.

@pranayberry not really. Mine _just_ looks for the remainder operator. Yours looks for the remainder operator and stuff being around it.

But to make it more explicit, it might be good to look for the correct use of the remainder operator with something like this:

assert(/var\\s*?remainder\\s*?=\\s*?.*%.*;/.test(code), 'message: You should use the <code>%</code> operator');

@erictleung Tested and working absolutely fine. Will submit the PR. :+1:

for this challenge, i entered

remainder = 11 % 3;

as my solution and got "You should use the % operator" error. can you confirm? I'm on a mac if that makes any difference.

@yuens1002 you need a var in front.

It is already declared from the line above
On Jun 3, 2016 2:36 PM, "Eric Leung" [email protected] wrote:

@yuens1002 https://github.com/yuens1002 you need a var in front.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/FreeCodeCamp/FreeCodeCamp/issues/8570#issuecomment-223700261,
or mute the thread
https://github.com/notifications/unsubscribe/AGSn-ywdbaFmmoXy7y_oD3I9LA1J40z1ks5qIJ5jgaJpZM4IcCQW
.

@yuens1002 mmm I see. We changed the test recently to look for var remainder = .... However, as long as the remainder = ...%... is there, it should be correct.

For anyone wanting to fix this, this line should be changed to:

"assert(/remainder\\s*?=\\s*?.*%.*;/.test(code), 'message: You should use the <code>%</code> operator');"

Please first read the contributing guidelines before taking care of this issue. And feel free to visit the Contributors Help chat room if you have any questions about helping. We're there to help.

Edit:
Additionally, you'll need to add another test to check for the initialization for remainder:

"assert(/var\\s*?remainder/.test(code), 'message: You should initialize the variable <code>remainder</code>');"

Best to check if the variable remainder has been declared elsewhere or not
have the variable remainder be declared by default.
On Jun 3, 2016 5:09 PM, "Eric Leung" [email protected] wrote:

@yuens1002 https://github.com/yuens1002 mmm I see. We changed the test
recently to look for var remainder = .... However, as long as the remainder
= ...%... is there, it should be correct.

For anyone wanting to fix this, this line
https://github.com/FreeCodeCamp/FreeCodeCamp/blob/staging/seed/challenges/01-front-end-development-certification/basic-javascript.json#L646
should be changed to:

"assert(/remainder\s_?=\s_?._%._;/.test(code), 'message: You should use the % operator');"

Please first read the contributing guidelines
https://github.com/FreeCodeCamp/FreeCodeCamp/blob/staging/CONTRIBUTING.md
before taking care of this issue. And feel free to visit the Contributors
Help https://gitter.im/FreeCodeCamp/HelpContributors chat room if you
have any questions about helping. We're there to help.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/FreeCodeCamp/FreeCodeCamp/issues/8570#issuecomment-223722200,
or mute the thread
https://github.com/notifications/unsubscribe/AGSn-wf8-iyhhQWkgvs3h97Ade95grX0ks5qIMIggaJpZM4IcCQW
.

Was this page helpful?
0 / 5 - 0 ratings