mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-30 21:03:58 -05:00
2.1 KiB
2.1 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| 56533eb9ac21ba0edf2244b7 | ربط المقاطع النصية باستخدام مشغل الجمع | 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.";