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

Variadic is binary function. #49

Open
jhowardjr opened this issue Feb 6, 2018 · 1 comment
Open

Variadic is binary function. #49

jhowardjr opened this issue Feb 6, 2018 · 1 comment
Assignees
Labels
help wanted Extra attention is needed

Comments

@jhowardjr
Copy link
Member

Help requested to create a variadic isBinary function that returns true if all the numbers in the parameter list are binary.

@jhowardjr jhowardjr added the help wanted Extra attention is needed label Feb 6, 2018
@D1esel-Dev D1esel-Dev self-assigned this Feb 7, 2018
@D1esel-Dev
Copy link

Alright so I need a few suggestions on this one guys:

here is my code so far:
image

My issue is after running this test:
image

I get this failure:
image

So I decided to do some manual tests to see what I get:
image

Acording to regExr everything matches:
image
So I can understand that .test() method will convert a number to a string if its not a string already, so 0110 is converted to 72 as the .toString() method on the regex prototype defaults the conversion to base 10 then it returns true cause 72 doesn't contain a 0 or 1. I can easily just make sure to convert the number to a binary string manually by using a param of 2 (binary radix), then have it do the regex test. But obviously we can not do this with every param passed in or then it will convert non-binary numbers to binary numbers, defeating well the purpose of the function.

I am also receiving this lint error:
image
This doesn't make sense cause Number.isNaN(0110) // false.

Should I string split any zeros out before its tested? Should I have a way to catch the binary representation of a number and return true instead of having it run through the regex .test() method?

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants