2.3 KiB
2.3 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244b8 | Concatenating Strings with the Plus Equals Operator | 1 | سلاسل متسلسلة مع Plus Equals Operator |
Description
+=
operator لسَلسَلة سلسلة في نهاية متغير سلسلة موجود. يمكن أن يكون هذا مفيدًا جدًا لكسر سلسلة طويلة عبر عدة أسطر. ملحوظة احترس من المساحات. لا يضيف Concatenation فراغات بين السلاسل المتسلسلة ، لذا ستحتاج إلى إضافتها بنفسك.
Instructions
myStr
عبر عدة سطور عن طريق وصل هاتين السلسلتين: "This is the first sentence. "
و "This is the second sentence."
باستخدام +=
عامل التشغيل. استخدم +=
عامل مشابه لكيفية ظهوره في المحرر. ابدأ بتخصيص السلسلة الأولى إلى myStr
، ثم أضفها في السلسلة الثانية. Tests
tests:
- text: يجب أن يكون لـ <code>myStr</code> قيمة <code>This is the first sentence. This is the second sentence.</code>
testString: 'assert(myStr === "This is the first sentence. This is the second sentence.", "<code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>");'
- text: استخدم <code>+=</code> عامل لبناء <code>myStr</code>
testString: 'assert(code.match(/\w\s*\+=\s*[""]/g).length > 1 && code.match(/\w\s*\=\s*[""]/g).length > 1, "Use the <code>+=</code> operator to build <code>myStr</code>");'
Challenge Seed
// Example
var ourStr = "I come first. ";
ourStr += "I come second.";
// Only change code below this line
var myStr;
After Test
console.info('after the test');
Solution
// solution required