Files
freeCodeCamp/curriculum/challenges/japanese/02-javascript-algorithms-and-data-structures/basic-javascript/finding-a-remainder-in-javascript.md
2023-03-13 19:41:01 +05:30

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 余り1
2 * 2 = 4
5 - 4 = 1

使用例
数学では、ある数が偶数か奇数かを求めるために、その数を 2 で割った余りを調べることができます。 偶数は 0 の余りを持ち、奇数は 1 の余りを持ちます。

17 % 2 = 1
48 % 2 = 0

注: 剰余演算子はしばしばモジュロ演算子と混同されることがあります。 剰余はモジュロと非常によく似ていますが、負数では正しく機能しません。

--instructions--

剰余 (%) 演算子を使用して、remainder113 で割った余りと等しくなるように設定してください。

--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;