This challenge has the following instructions:
Adds two numbers together and returns their sum in binary.
The binary number returned should be a string.
The first step is simply adding numbers to a sum,
The second step here intoducing toString() method, what it does is passing in an value and convert it based on numeral system.
Let's look at some basic number systems:
1.Decimal number system (Base- 10)
2.Binary number system (Base- 2)
3.Octal number system (Base-8)
4.Hexadecimal number system (Base- 16)
In this case, the solution will be:
Take it to the next level, using arrow function expression:
One thing to keep in mind is that, you can only pass in from range 2 through 36, otherwise [Range error] is thrown.
Happy coding!
Bonus challenge: How to convert your name into binary representation? ʕ•́ᴥ•̀ʔっ
Top comments (0)