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

Tell us what’s happening:

I’m confused as to how decimalToBinary(5) makes 10, since 5 / 2 is 2.5.
This is the step where we put
“decimalToBinary(5) returns ‘10’ + 1 (5 % 2). Then it pops off the stack.”

Your code so far

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

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

  {
    inputVal: 5,
    addElDelay: 1000
  },

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Safari/605.1.15

Challenge Information:

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

5 / 2 is 2 with rest of 1. % gives you the rest, so 5 % 2 is 1

I understand the part about the remainder but 5 / 2 is 2.5, so idk how it returns 10

Hi @victoriat420

Step 101 is part of a sequence. You need to complete the last step to see how it is all put together.

% means modulus.
The modulus operator divides two numbers and returns the remainder.

Happy coding

where do you see 5 / 2?
I only see 5 % 2 and that returns the remainder, which is 1

Cause 5 is the input and the input is divided by 2 in the decimalToBinary function

there is also a Math.floor, so the result of the division is rounded down to the nearest integer