Freecodecamp: TypeError: Finding a Remainder in Javascript

Created on 1 Jan 2016  路  12Comments  路  Source: freeCodeCamp/freeCodeCamp

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

My code:

// Only change code below this line

var remainder = 11 % 3

if i add a semicolon at the end it does pass.

All 12 comments

@DDaems Initial look into this and I see the following from Developer Console when the error is thrown

var remainder = 11 % 3
(function(y){return 'remainder = '+y;})(remainder);

leading to incorrectly interrupting your code as 3(...)(remainder); and since as we know 3 is not a function, we get TypeError: 3 is not a function as error.

Hence it is always good to add ; at the end of each statement because we have no idea what other code runs along in the backend.

More detailed explanation can come from core FCC member (if required)

@smrajagopal The supplied code is still valid and should not trow a TypeError. Its a bug, that should be addressed.

This is an unavoidable side effect of the way the code is executed and there's a linting error on the side saying a semicolon should be added, so I don't think this is a problem.

Thanks and happy coding!

@ltegman

I agree that this isn't a really big problem, certainly nothing dealbreaking.
But this is still a bug that could be pointed out to the module creator/maintainers.

Can we maybe leave it open temporarly with some tags as: 'low-priority', 'fcc-core', 'hard'?
Untill someone has passed it along to the creator/maintainers of the module.
So this bug doesn't dissapear in the void, because its not all to important.

@BerkeleyTrue @SaintPeter
Opinions on this?

I'll leave it up to @BerkeleyTrue whether this is something that should be reopened for a fix or not. I've seen similar bugs closed in the past which is why I closed it.

The supplied code is still valid and should not trow a TypeError.

This is a syntax error and the reason you should always use semicolons. Always use semicolons and you won't run into this problem.

Happy Coding!

removed solution by mod

I have no idea why you bumped this issue providing a answer, because its exactly not what this is about. Anyway, i might aswell thank you. Else i likely wouldn't have fixed it. ;-)

I bumped this issue for the sole purpose of you not having a idea lmao

_removed solution by mod_

removed solution by mod

removed solution by mod

Was this page helpful?
0 / 5 - 0 ratings

Related issues

imhuyqn picture imhuyqn  路  3Comments

itsmikewest picture itsmikewest  路  3Comments

trashtalka3000 picture trashtalka3000  路  3Comments

ar5had picture ar5had  路  3Comments

raisedadead picture raisedadead  路  3Comments