mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-31 06:01:50 -05:00
2.0 KiB
2.0 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| 56533eb9ac21ba0edf2244ed | إلحاق المتغيرات بالمقاطع النصية (Appending Variables to Strings) | 1 | https://scrimba.com/c/cbQmZfa | 16656 | appending-variables-to-strings |
--description--
تماما كما يمكننا بناء مقطع نصي (string) مكونة من عدة سطور باستخدام الاحرف مقطع نصي (string literals)، يمكننا أيضا إلحاق المتغيرات في مقطع نصي (string) معينة باستخدام (+=).
على سبيل المثال:
const anAdjective = "awesome!";
let ourStr = "freeCodeCamp is ";
ourStr += anAdjective;
المتغير ourStr ستكون قيمته النهائية freeCodeCamp is awesome!.
--instructions--
عرف متغير جديد someAdjective بحيث يكون string قيمته مكون من 3 أحرف في الأقل, ثم إلحاقه بمتغير آخر myStr باستخدام +=.
--hints--
يجب إن تكون قيمة المتغير someAdjective مقطع نصي (string) مكون من 3 حروف في الأقل.
assert(typeof someAdjective !== 'undefined' && someAdjective.length > 2);
يجب عليك إلحاق المتغير someAdjective إلى myStr باستخدام +=.
assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0);
--seed--
--after-user-code--
(function(){
var output = [];
if(typeof someAdjective === 'string') {
output.push('someAdjective = "' + someAdjective + '"');
} else {
output.push('someAdjective is not a string');
}
if(typeof myStr === 'string') {
output.push('myStr = "' + myStr + '"');
} else {
output.push('myStr is not a string');
}
return output.join('\n');
})();
--seed-contents--
// Change code below this line
const someAdjective = "";
let myStr = "Learning to code is ";
--solutions--
const someAdjective = "neat";
let myStr = "Learning to code is ";
myStr += someAdjective;