2.9 KiB
2.9 KiB
id | title | isRequired | challengeType | videoUrl | localeTitle |
---|---|---|---|---|---|
afcc8d540bea9ea2669306b6 | Repeat a String Repeat a String | true | 5 | كرر سلسلة يكرر سلسلة |
Description
str
سلسلة معينة (الوسيطة الأولى) لـ num
times (الوسيطة الثانية). إرجاع سلسلة فارغة إذا لم تكن num
رقم موجب. تذكر استخدام Read-Search-Ask إذا واجهتك مشكلة. اكتب الكود الخاص بك. Instructions
Tests
tests:
- text: 'يجب أن ترجع <code>repeatStringNumTimes("*", 3)</code> <code>"***"</code> .'
testString: 'assert(repeatStringNumTimes("*", 3) === "***", "<code>repeatStringNumTimes("*", 3)</code> should return <code>"***"</code>.");'
- text: 'يجب أن ترجع <code>repeatStringNumTimes("abc", 3)</code> <code>"abcabcabc"</code> .'
testString: 'assert(repeatStringNumTimes("abc", 3) === "abcabcabc", "<code>repeatStringNumTimes("abc", 3)</code> should return <code>"abcabcabc"</code>.");'
- text: 'يجب أن ترجع <code>repeatStringNumTimes("abc", 4)</code> <code>"abcabcabcabc"</code> .'
testString: 'assert(repeatStringNumTimes("abc", 4) === "abcabcabcabc", "<code>repeatStringNumTimes("abc", 4)</code> should return <code>"abcabcabcabc"</code>.");'
- text: 'يجب أن ترجع <code>repeatStringNumTimes("abc", 1)</code> <code>"abc"</code> .'
testString: 'assert(repeatStringNumTimes("abc", 1) === "abc", "<code>repeatStringNumTimes("abc", 1)</code> should return <code>"abc"</code>.");'
- text: 'يجب أن ترجع <code>repeatStringNumTimes("*", 8)</code> <code>"********"</code> .'
testString: 'assert(repeatStringNumTimes("*", 8) === "********", "<code>repeatStringNumTimes("*", 8)</code> should return <code>"********"</code>.");'
- text: 'يجب أن ترجع <code>repeatStringNumTimes("abc", -2)</code> <code>""</code> .'
testString: 'assert(repeatStringNumTimes("abc", -2) === "", "<code>repeatStringNumTimes("abc", -2)</code> should return <code>""</code>.");'
- text: لا يجب استخدام <code>repeat()</code> المدمج <code>repeat()</code> -method
testString: 'assert(!/\.repeat/g.test(code), "The built-in <code>repeat()</code>-method should not be used");'
Challenge Seed
function repeatStringNumTimes(str, num) {
// repeat after me
return str;
}
repeatStringNumTimes("abc", 3);
Solution
// solution required