mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-30 21:03:58 -05:00
1.4 KiB
1.4 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| 56533eb9ac21ba0edf2244ae | 求余运算 | 1 | https://scrimba.com/c/cWP24Ub | 18184 | finding-a-remainder-in-javascript |
--description--
remainder 求余运算符 % 返回两个数相除得到的余数
示例
5 % 2 = 1 5 / 2 = 2 remainder 1 2 * 2 = 4 5 - 4 = 1
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. Even numbers have a remainder of 0, while odd numbers a remainder of 1.
17 % 2 = 1 48 % 2 = 0
提示余数运算符(remainder)有时被错误地称为“模数”运算符。 它与模数非常相似,但不能用于负数的运算。
--instructions--
使用 remainder (%)运算符,计算 11 除以 3 的余数,并把余数赋给变量 remainder。
--hints--
变量 remainder 应该被初始化。
assert(/(const|let|var)\s+?remainder/.test(code));
remainder 的值应该等于 2。
assert(remainder === 2);
你应该使用 % 运算符。
assert(/\s+?remainder\s*?=\s*?.*%.*;?/.test(code));
--seed--
--after-user-code--
(function (y) {
return 'remainder = ' + y;
})(remainder);
--seed-contents--
const remainder = 0;
--solutions--
const remainder = 11 % 3;