mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-12 10:00:39 -04:00
1.7 KiB
1.7 KiB
id, title, challengeType, forumTopicId, dashedName
| id | title | challengeType | forumTopicId | dashedName |
|---|---|---|---|---|
| 587d7dbb367417b2b2512bac | إزالة Whitespace من البداية و النهاية (Remove Whitespace from Start and End) | 1 | 301362 | remove-whitespace-from-start-and-end |
--description--
في بعض الأحيان لا تكون الـ whitespaces حول الـ strings مطلوبة ولكنها موجودة. المعالجة النموذجية للـ strings هي إزالة الـ whitespace في بدايتها ونهايتها.
--instructions--
اكتب regex و استخدم الطرق المناسبة لإزالة الـ whitespace في بداية و نهاية الـ strings.
ملاحظة: طريقة String.prototype.trim() ستعمل هنا، ولكن ستحتاج إلى إكمال هذا التحدي باستخدام regular expressions.
--hints--
result يجب أن تكون مساوية للـ string الآتي Hello, World!
assert(result === 'Hello, World!');
يجب ألا يستخدم حلك طريقة String.prototype.trim().
assert(!__helpers.removeJSComments(code).match(/\.?[\s\S]*?trim/));
متغير النتيجة result يجب ألا يتم تعيينه مباشرة إلى string
assert(!__helpers.removeJSComments(code).match(/result\s*=\s*["'`].*?["'`]/));
لا ينبغي تغيير قيمة متغير hello.
assert(hello === ' Hello, World! ');
--seed--
--seed-contents--
let hello = " Hello, World! ";
let wsRegex = /change/; // Change this line
let result = hello; // Change this line
--solutions--
let hello = " Hello, World! ";
let wsRegex = /^(\s+)(.+[^\s])(\s+)$/;
let result = hello.replace(wsRegex, '$2');