← Back to challenges

Decimal to Binary Using Stack

JavaScriptHarddata_structuresalgorithms

Instructions

Create a function that takes a decimal number and converts it to a binary number using Stack. The Stack is created for you.

Examples

toBinary(12) ➞ 1100

toBinary(0) ➞ 0

toBinary(101) ➞ 1100101

Notes

0 <= n <= 101

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: ES6: Destructuring Objects VII