0
Why is this not recognised as a function
I am training to work with classes for a bit now, but I can't find out why sometimes this.doSomething is not recognised as a function. https://code.sololearn.com/WDfXd4NVBplu/?ref=app
4 Answers
+ 4
The problem here is your making a new instance of the "num" class (good) but then your immediately calling the "toBinary" method on it so q is not a new instance of that class but the value that the used method returns. So, for example, if you input 119 q would be equal to: 1110111 (119 in binary) and of course, that number does not have the "isBinary" method hence the error message.
Anyway, that's enough rambling for now đ
here is the solution:
https://code.sololearn.com/WkFCgRMOa3Pk/?ref=app
+ 3
With the way you have it setup now, yes, that would change its x property to a binary number.
+ 1
So what you're saying is in order to let q be a binary number (1110111) I would have to change the toBinary method from a returning method to a this.x = (this.x >>> 0).toString(2);
0
Ok thanks!



