DEV Community

Discussion on: #27 Guess The Output ???

Collapse
 
jayjeckel profile image
Jay Jeckel

It can't be 15 as one would intuitively think. So, thinking what kind of wrong thing javascript could do, I'm guessing the leading zero is treated as some kind of literal prefix that changes the base of the number. Fives wouldn't be valid for binary, so possibly hex, which would make 55 actually equal to decimal 85 and the final answer 45.

But that would still be too logical, as hex is generally useful, so I'm guessing it isn't hex, but a less used base... so maybe base 12 or 8. I can't think of the name for base 12, but octal has a simple name and isn't very useful, so I'm going to guess that it's octal.

Then octal 055 actually equals decimal 45 and the result is 45 - 35 - 5 == 5.

Collapse
 
shamgurav96 profile image
Sham Gurav

Your answer is correct and Your guessing game is on point. Getting kind of Sherlock Holms vibess .....