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

Tell us what’s happening:

This is my code for covert base10 to base2
But it show error “Your decimalToBinary function should return “1010” as a string.” I write log and it show 1010 already

const decimalToBinary = (input) => {
let quotient = input;
let result = “”;

while (quotient > 0) {
let remainder = quotient % 2;
result = remainder.toString() + result;
quotient = Math.floor(quotient / 2)

return result.padStart(4, "0");

};

Your code so far

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

/* file: styles.css */

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

  let quotient = input;

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36

Challenge Information:

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

hello @Suchansinee-nice welcome back!

I am guessing this step is just for practice and checks your understanding of the decimal to binary conversion. Because it wants you to do the calculation by yourself and just return the result of converting 10 into binary as a string (kind of asking you ‘what will be its result if input was 10?’). You do not actually need to write the code to convert the input yet in this step.

Thank you so much. :folded_hands::folded_hands: :folded_hands: @sampatee