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

Tell us what’s happening:

I just really cant grasp the meaning of the statement . Could anyone explain more : “First, use the remainder operator (% ) to set binary equal to the remainder of input divided by 2 .”

Your code so far


const decimalToBinary = (input) => {
  let binary = "";

  while (input > 0) {

// User Editable Region

binary %= input / 2


// User Editable Region

  

### Challenge Information:
Learn Recursion by Building a Decimal to Binary Converter - Step 40
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-recursion-by-building-a-decimal-to-binary-converter/step-40

Hello @sonuipad05

The request as you posted says:

First, use the remainder operator (%) to set binary equal to the remainder of input divided by 2.

When you use the % operator the computer is dividing the first operand by the second term and it throws away the result of the division. It does however return as result if there was a remainder left from divining and how much it was.

So, it is asking to use this operator with the value in input and the integer 2 and the result to be assigned back to the variable binary
Notice that there is no division that you need to tell it to perform.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.