# freeCodeCamp Challenge Guide: Finding a Remainder in JavaScript

**URL:** <https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184>\
**Category:** freeCodeCamp Contributors\
**Tags:** guide\
**Created:** [July 7, 2016, 8:18pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184 "2016-07-07T20:18:06Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![camperbot](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/camperbot/32/18364_2.png) [@camperbot](https://forum.freecodecamp.org/u/camperbot)\
**Post date:** [July 7, 2016, 8:18pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/1 "2016-07-07T20:18:06Z")

</div>

# [Finding a Remainder in JavaScript](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/finding-a-remainder-in-javascript)

* * *

## Hints

### Hint 1

The remainder operator `%` gives the remainder of the division of two numbers.

```javascript
var remainder = 11 % 3; //remainder gets the value 2

```

---

<div class="post-metadata">

**Author:** ![Sturke](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sturke/32/95318_2.png) [@Sturke](https://forum.freecodecamp.org/u/Sturke)\
**Post date:** [January 18, 2017, 8:22am UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/2 "2017-01-18T08:22:04Z")

</div>

I have been struggling to get this formatted correctly. Any help would be appreciated. I put:

(11 % 3 = 2);

for my answer and it has a yellow caution triangle and says “Bad Assignment” pointing to the equals sign.

---

<div class="post-metadata">

**Author:** ![kaiogyn](https://avatars.discourse-cdn.com/v4/letter/k/b2d939/32.png) [@kaiogyn](https://forum.freecodecamp.org/u/kaiogyn)\
**Post date:** [January 23, 2017, 3:45pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/3 "2017-01-23T15:45:22Z")

</div>

var remainder = 2 % 11;

---

<div class="post-metadata">

**Author:** ![Forum](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/forum/32/68049_2.png) [@Forum](https://forum.freecodecamp.org/u/Forum)\
**Post date:** [May 19, 2017, 4:17pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/4 "2017-05-19T16:17:45Z")

</div>

The remainder operator % gives the remainder of the division of two numbers.  
**Example**  
**Usage**  
**Note**

**Instructions**  
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.

1. The variable remainder should be initialized  
`var remainder`

2)The value of remainder should be 2  
`var remainder = 2;`

1. You should use the % operator  
var remainder = 2%11;

`

---

<div class="post-metadata">

**Author:** ![maxcarlisle](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/maxcarlisle/32/51812_2.png) [@maxcarlisle](https://forum.freecodecamp.org/u/maxcarlisle)\
**Post date:** [July 27, 2017, 11:30pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/5 "2017-07-27T23:30:43Z")

</div>

Can anyone clarify what they’re saying here?

17 % 2 = 1 (17 is Odd)  
48 % 2 = 0 (48 is Even)

“Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.”

var remainder = 2%11;

Where did 11 / 3 go?

---

<div class="post-metadata">

**Author:** ![Rickesh2010](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/rickesh2010/32/61420_2.png) [@Rickesh2010](https://forum.freecodecamp.org/u/Rickesh2010)\
**Post date:** [July 30, 2017, 10:52pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/6 "2017-07-30T22:52:30Z")

</div>

> [@Forum](#):
>
> 2%11;

The above was an example. It is pretty easy but everyone has to be verbose when explaining shit here.

For 11 % 3 all you do is divide 11/3, which =3 with a remainder of 2.

can double check by 3x3=9  
11-9=2(same as the remainder)

---

<div class="post-metadata">

**Author:** ![enfrte](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/enfrte/32/67757_2.png) [@enfrte](https://forum.freecodecamp.org/u/enfrte)\
**Post date:** [August 1, 2017, 10:15pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/7 "2017-08-01T22:15:14Z")

</div>

I have no idea what the final part of this task was on about.

I understand the following  
`17 % 2 = 1 (17 is Odd)`  
`48 % 2 = 0 (48 is Even)`

In the final part, the correct answer is `var remainder = 2 % 11;`, but I have no idea what this has to do with `11 / 3`.

---

<div class="post-metadata">

**Author:** ![lizabelle](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lizabelle/32/161552_2.png) [@lizabelle](https://forum.freecodecamp.org/u/lizabelle)\
**Post date:** [August 3, 2017, 6:37pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/8 "2017-08-03T18:37:53Z")

</div>

I entered “var remainder = 11 % 3;”, which the system accepted as correct. However, looking here I see var remainder = 2 % 11; is supposed to be the correct answer. Can anyone please clarify whether 11 % 3 really is the correct syntax, and if not, why not? TIA.

---

<div class="post-metadata">

**Author:** ![enfrte](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/enfrte/32/67757_2.png) [@enfrte](https://forum.freecodecamp.org/u/enfrte)\
**Post date:** [August 4, 2017, 6:13pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/9 "2017-08-04T18:13:40Z")

</div>

I think it’s this

```
var remainder = 11 % 3;
```

---

<div class="post-metadata">

**Author:** ![enfrte](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/enfrte/32/67757_2.png) [@enfrte](https://forum.freecodecamp.org/u/enfrte)\
**Post date:** [August 4, 2017, 6:22pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/10 "2017-08-04T18:22:02Z")

</div>

Some info about the operator [https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Arithmetic\_Operators#Remainder\_()](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder_())

I think free code camp accepts the answer because the result of `2 % 11` is coincidentally the same `11 % 3`.

I got a bit confused about what they wanted, because they were talking about finding whether a number was odd or even earlier on in the tutorial.

---

<div class="post-metadata">

**Author:** ![camperbot](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/camperbot/32/18364_2.png) [@camperbot](https://forum.freecodecamp.org/u/camperbot)\
**Post date:** [August 10, 2019, 1:20am UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/12 "2019-08-10T01:20:51Z")

</div>



---

<div class="post-metadata">

**Author:** ![KittyKora](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kittykora/32/124629_2.png) [@KittyKora](https://forum.freecodecamp.org/u/KittyKora)\
**Post date:** [September 11, 2019, 5:47pm UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/13 "2019-09-11T17:47:42Z")

</div>

> [@enfrte](#):
>
> var remainder = 11 % 3;

There are several answeres possible you can also sollute the lesson by

```auto
var remainder = 11 % 3;

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 7, 2025, 11:59am UTC](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-finding-a-remainder-in-javascript/18184/14 "2025-01-07T11:59:33Z")

</div>


