mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-30 21:03:58 -05:00
2.2 KiB
2.2 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| 56533eb9ac21ba0edf2244b7 | ربط المقاطع النصية باستخدام مشغل الجمع (Concatenating Strings with Plus Operator) | 1 | https://scrimba.com/c/cNpM8AN | 16802 | concatenating-strings-with-plus-operator |
--description--
في JavaScript، عندما يستخدم مشغل + مع String، فإنه يسمى مشغل سلسلة. يمكنك بناء مقطع جديد من المقاطع الأخرى من طريق تجميع السلسلة بعضها مع بعض.
مثال
'My name is Alan,' + ' I concatenate.'
ملاحظة: احترس من المسافات. لإن ربط السلسلة لا تضيف مسافات بين المقاطع الذي تم جمعها، لذا ستحتاج إلى إضافتها بنفسك.
مثال:
const ourStr = "I come first. " + "I come second.";
المقطع الآتي I come first. I come second. سيتم عرضه في وحدة التحكم.
--instructions--
أنشئ myStr من المقاطع الآتية This is the start. و This is the end. باستخدام المشغل +. تيقن من تضمين مسافة بين المقاطع.
--hints--
يجب أن يوجد حرف الفراغ واحد بين المقطعين في myStr.
assert(/start\. This/.test(myStr));
يجب أن يكون قيمة myStr النص الآتي This is the start. This is the end.
assert(myStr === 'This is the start. This is the end.');
يجب عليك استخدام مشغل + لبناء myStr.
assert(code.match(/(["']).*\1\s*\+\s*(["']).*\2/g));
يجب أن يتم إنشاء myStr باستخدام كلمة const.
assert(/const\s+myStr/.test(code));
يجب عليك تعيين النتيجة إلى متغير myStr.
assert(/myStr\s*=/.test(code));
--seed--
--after-user-code--
(function(){
if(typeof myStr === 'string') {
return 'myStr = "' + myStr + '"';
} else {
return 'myStr is not a string';
}
})();
--seed-contents--
const myStr = ""; // Change this line
--solutions--
const myStr = "This is the start. " + "This is the end.";