3.2 KiB
3.2 KiB
id | title | isRequired | challengeType | videoUrl | localeTitle |
---|---|---|---|---|---|
a5deed1811a43193f9f1c841 | Drop it | true | 5 | أسقطها |
Description
arr
، قم بالتمرير عبر كل عنصر بدءًا من العنصر الأول (مؤشر 0) وإزالته إلى أن تعود الدالة func
إلى true
عند تمرير العنصر المتكرر عبرها. ثم أعد بقية المصفوفة بمجرد استيفاء الشرط ، وإلا ، يجب إرجاع arr
كصفيف فارغ. تذكر استخدام Read-Search-Ask إذا واجهتك مشكلة. حاول إقران البرنامج. اكتب الكود الخاص بك. Instructions
Tests
tests:
- text: '<code>dropElements([1, 2, 3, 4], function(n) {return n >= 3;})</code> return <code>[3, 4]</code> .'
testString: 'assert.deepEqual(dropElements([1, 2, 3, 4], function(n) {return n >= 3;}), [3, 4], "<code>dropElements([1, 2, 3, 4], function(n) {return n >= 3;})</code> should return <code>[3, 4]</code>.");'
- text: '<code>dropElements([0, 1, 0, 1], function(n) {return n === 1;})</code> بإرجاع <code>[1, 0, 1]</code> .'
testString: 'assert.deepEqual(dropElements([0, 1, 0, 1], function(n) {return n === 1;}), [1, 0, 1], "<code>dropElements([0, 1, 0, 1], function(n) {return n === 1;})</code> should return <code>[1, 0, 1]</code>.");'
- text: '<code>dropElements([1, 2, 3], function(n) {return n > 0;})</code> return <code>[1, 2, 3]</code> .'
testString: 'assert.deepEqual(dropElements([1, 2, 3], function(n) {return n > 0;}), [1, 2, 3], "<code>dropElements([1, 2, 3], function(n) {return n > 0;})</code> should return <code>[1, 2, 3]</code>.");'
- text: '<code>dropElements([1, 2, 3, 4], function(n) {return n > 5;})</code> return <code>[]</code> .'
testString: 'assert.deepEqual(dropElements([1, 2, 3, 4], function(n) {return n > 5;}), [], "<code>dropElements([1, 2, 3, 4], function(n) {return n > 5;})</code> should return <code>[]</code>.");'
- text: '<code>dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;})</code> يجب أن تعود <code>[7, 4]</code> .'
testString: 'assert.deepEqual(dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;}), [7, 4], "<code>dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;})</code> should return <code>[7, 4]</code>.");'
- text: '<code>dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})</code> يجب أن تعود <code>[3, 9, 2]</code> .'
testString: 'assert.deepEqual(dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}), [3, 9, 2], "<code>dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})</code> should return <code>[3, 9, 2]</code>.");'
Challenge Seed
function dropElements(arr, func) {
// Drop them elements.
return arr;
}
dropElements([1, 2, 3], function(n) {return n < 3; });
Solution
// solution required