2.8 KiB
2.8 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7b7b367417b2b2512b17 | Combine Arrays with the Spread Operator | 1 | الجمع بين المصفوفات مع المشغل انتشار |
Description
دع هذا aarray = ['sage'، 'rosemary'، 'parsley'، 'thyme']؛باستخدام صيغة الانتشار ، حققنا للتو عملية من شأنها أن تكون أكثر تعقيدا وأكثر استعراضا لو استخدمنا الطرق التقليدية.
اترك ذلكالرائحة = ['basil' ، 'cilantro' ، ... thisArray ، 'الكزبرة'] ؛
/ / أن الآن يساوي [basil] ، 'cilantro' ، 'sage' ، 'rosemary' ، 'parsley' ، 'thyme' ، 'coriander']
Instructions
spreadOut
التي تقوم بارجاع sentence
المتغيرة ، قم بتعديل الوظيفة باستخدام معامل الانتشار بحيث يقوم بإرجاع الصفيف ['learning', 'to', 'code', 'is', 'fun']
. Tests
tests:
- text: '<code>spreadOut</code> يجب أن تعود <code>["learning", "to", "code", "is", "fun"]</code>'
testString: 'assert.deepEqual(spreadOut(), ["learning", "to", "code", "is", "fun"], "<code>spreadOut</code> should return <code>["learning", "to", "code", "is", "fun"]</code>");'
- text: يجب أن تستخدم دالة <code>spreadOut</code> بنية الانتشار
testString: 'assert.notStrictEqual(spreadOut.toString().search(/[...]/), -1, "The <code>spreadOut</code> function should utilize spread syntax");'
Challenge Seed
function spreadOut() {
let fragment = ['to', 'code'];
let sentence; // change this line
return sentence;
}
// do not change code below this line
console.log(spreadOut());
Solution
// solution required