Files
freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/basic-javascript/finding-a-remainder-in-javascript.md
2023-02-20 20:31:01 +01:00

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

مشغل المتبقي الآتي % يعطي الجزء المتبقي من عملية تقسيم رقمين.

مثال

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

ملاحظة: مشغل المتبقي يشار إليه أحياناً بشكل غير صحيح على أنه مشغل بالمائة (modulus operator). إنه شبيه جداً بالـمائه (modulus)، ولكنه لا يعمل بشكل صحيح مع الأعداد السالبة.

--instructions--

عيّن remainder مساوية لبقية 11 مقسوما على 3 باستخدام مشغل المتبقي الآتي (%).

--hints--

يجب تهيئة المتغير remainder. بمعنى آخر، يجب أن يكون initialized

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;