← Back to challenges

Hex to Binary

JavaScriptHardbit_operations

Instructions

Create a function that will take a HEX number and returns the binary equivalent (as a string).

Examples

toBinary(0xFF) ➞ "11111111"

toBinary(0xAA) ➞ "10101010"

toBinary(0xFA) ➞ "11111010"

Notes

The number will be always an 8-bit number.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Older Than Me