--- id: 56533eb9ac21ba0edf2244ae title: Finding a Remainder in JavaScript challengeType: 1 videoUrl: 'https://scrimba.com/c/cWP24Ub' --- ## Description
The remainder operator % gives the remainder of the division of two numbers. Example
5 % 2 = 1 because
Math.floor(5 / 2) = 2 (Quotient)
2 * 2 = 4
5 - 4 = 1 (Remainder)
Usage
In mathematics, a number can be checked to be even or odd by checking the remainder of the division of the number by 2.
17 % 2 = 1 (17 is Odd)
48 % 2 = 0 (48 is Even)
Note
The remainder operator is sometimes incorrectly referred to as the "modulus" operator. It is very similar to modulus, but does not work properly with negative numbers.
## Instructions
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
## Tests
```yml tests: - text: The variable remainder should be initialized testString: assert(/var\s+?remainder/.test(code)); - text: The value of remainder should be 2 testString: assert(remainder === 2); - text: You should use the % operator testString: assert(/\s+?remainder\s*?=\s*?.*%.*;/.test(code)); ```
## Challenge Seed
```js // Only change code below this line var remainder; ```
### After Test
```js (function(y){return 'remainder = '+y;})(remainder); ```
## Solution
```js var remainder = 11 % 3; ```