mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-19 09:02:35 -05:00
1.6 KiB
1.6 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| 56533eb9ac21ba0edf2244ae | JavaScript で割り算の余りを求める | 1 | https://scrimba.com/c/cWP24Ub | 18184 | finding-a-remainder-in-javascript |
--description--
剰余演算子 % は 2 つの数値の割り算の余りを取得します。
例
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
注: 剰余演算子はしばしばモジュロ演算子と混同されることがあります。 剰余はモジュロと非常によく似ていますが、負数では正しく機能しません。
--instructions--
剰余 (%) 演算子を使用して、remainder が 11 を 3 で割った余りと等しくなるように設定してください。
--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;