--- id: 56533eb9ac21ba0edf2244ae title: Finding a Remainder in JavaScript challengeType: 1 videoUrl: '' localeTitle: 在JavaScript中查找剩余内容 --- ## Description
余数运算符%给出了两个数的除法的余数。
5%2 = 1因为
Math.floor(5/2)= 2(商数)
2 * 2 = 4
5 - 4 = 1(剩余)
用法
在数学中,通过检查数字除以2的余数,可以检查数字是偶数还是奇数。
17%2 = 1(17为奇数)
48%2 = 0(48为偶数)
注意
余数运算符有时被错误地称为“模数”运算符。它与模数非常相似,但在负数下不能正常工作。
## Instructions
使用余数% )运算符将remainder设置为等于11的余数除以3
## Tests
```yml tests: - text: 应该初始化变量remainder testString: 'assert(/var\s+?remainder/.test(code), "The variable remainder should be initialized");' - text: remainder的值应为2 testString: 'assert(remainder === 2, "The value of remainder should be 2");' - text: 您应该使用%运算符 testString: 'assert(/\s+?remainder\s*?=\s*?.*%.*;/.test(code), "You should use the % operator");' ```
## Challenge Seed
```js // Only change code below this line var remainder; ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```