You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alright so I need a few suggestions on this one guys:
here is my code so far:
My issue is after running this test:
I get this failure:
So I decided to do some manual tests to see what I get:
Acording to regExr everything matches:
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:
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?
Help requested to create a variadic
isBinary
function that returns true if all the numbers in the parameter list are binary.The text was updated successfully, but these errors were encountered: