Files
freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/debugging/catch-missing-open-and-closing-parenthesis-after-a-function-call.md
2023-01-03 11:16:51 -06:00

2.2 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d7b85367417b2b2512b39 إدراك أقواس (Parenthesis) الفتح والإغلاق المفقودة بعد تفعيل وظيفة (Function) 1 301185 catch-missing-open-and-closing-parenthesis-after-a-function-call

--description--

عندما لا تأخذ الوظيفة (function) أو الطريقة (method) أي معطيات (arguments)، قد تنسى إدراج أقواس الفتح والإغلاق (فارغة) عند تفعيلها. غالباً ما يتم حفظ نتيجة تفعيل وظيفة (function) في متغير (variable) لاستخدام آخر في كودك. يمكن اكتشاف هذا الخطأ عن طريق تسجيل قيم المتغيرات (variables) (أو أنواعها) إلى الوحدة (console) وملاحظة أن القيمة المعينة للمتغير (variable) هي مرجع وظيفة (function reference)، بدلاً من القيمة المتوقعة وهي ناتج تنفيذ الوظيفة (function).

فتختلف المتغيرات الواردة في المثال التالي:

function myFunction() {
  return "You rock!";
}
let varOne = myFunction;
let varTwo = myFunction();

تكون varOne الوظيفة (function) هنا مسمى myFunction، ويكون varTwo المقطع نصي (string) من You rock!.

--instructions--

أصلح الكود بحيث يتم تعيين المتغير (variable) المسمى result بقيمة الناتحة من تفعيل الوظيفة (function) مسمى getNine.

--hints--

يجب أن يصلح الوظيفة المتغير (variable) مسمى result حيث يتم تعيينه الرَّقْم الذي ينتج الوظيفة (function) مسمى getNine.

assert(result == 9);

يجب أن يفعيل كودك وظيفة getNine.

assert(code.match(/getNine\(\)/g).length == 2);

--seed--

--seed-contents--

function getNine() {
  let x = 6;
  let y = 3;
  return x + y;
}

let result = getNine;
console.log(result);

--solutions--

function getNine() {
 let x = 6;
 let y = 3;
 return x + y;
}

let result = getNine();
console.log(result);