Learn Recursion by Building a Decimal to Binary Converter - Step 39

Tell us what’s happening:

i am not able to pass the requirements of the test
the test asks that inside the while loop, set input equal to quotient of input divided by 2. also, remember to use Math.floor() to round the quotient down
script.js
const decimalToBinary = (input) => {
let binary = “”;

while (input > 0) {
input = 0;
input = Math.floor(input / 2);
}

Your code so far

<!-- file: index.html -->

/* file: script.js */
// User Editable Region

    input = 0;
    input = Math.floor(input / 2);

// User Editable Region
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36

Challenge Information:

Learn Recursion by Building a Decimal to Binary Converter - Step 39

Remove the code that sets input to 0

You are meant to update that code to what you have on the next line.

1 Like