1.9 KiB
1.9 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244ae | Finding a Remainder in JavaScript | 1 | 在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
tests:
- text: 应该初始化变量<code>remainder</code>
testString: 'assert(/var\s+?remainder/.test(code), "The variable <code>remainder</code> should be initialized");'
- text: <code>remainder</code>的值应为<code>2</code>
testString: 'assert(remainder === 2, "The value of <code>remainder</code> should be <code>2</code>");'
- text: 您应该使用<code>%</code>运算符
testString: 'assert(/\s+?remainder\s*?=\s*?.*%.*;/.test(code), "You should use the <code>%</code> operator");'
Challenge Seed
// Only change code below this line
var remainder;
After Test
console.info('after the test');
Solution
// solution required