2.3 KiB
2.3 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56105e7b514f539506016a5e | Count Backwards With a For Loop | 1 | عد إلى الخلف مع ل حلقة |
Description
initialization
condition
final-expression
. سنبدأ عند i = 10
والحلقة بينما i > 0
. سنقوم decrement i
كل حلقة 2 مع i -= 2
. var ourArray = []؛
for (var i = 10؛ i> 0؛ i- = 2) {
ourArray.push (ط)؛
}
ourArray
الآن [10,8,6,4,2]
. دعونا نغير initialization
final-expression
حتى نتمكن من العد إلى الوراء من خلال الاثنتين بالأرقام الفردية. Instructions
myArray
باستخدام حلقة for
. Tests
tests:
- text: يجب أن تكون باستخدام <code>for</code> حلقة لهذا الغرض.
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
- text: يجب أن تستخدم <code>push</code> طريقة الصفيف.
testString: 'assert(code.match(/myArray.push/), "You should be using the array method <code>push</code>.");'
- text: '<code>myArray</code> ينبغي أن تساوي <code>[9,7,5,3,1]</code> .'
testString: 'assert.deepEqual(myArray, [9,7,5,3,1], "<code>myArray</code> should equal <code>[9,7,5,3,1]</code>.");'
Challenge Seed
// Example
var ourArray = [];
for (var i = 10; i > 0; i -= 2) {
ourArray.push(i);
}
// Setup
var myArray = [];
// Only change code below this line.
After Test
console.info('after the test');
Solution
// solution required