Microsoft
98-382 · Question #13
Declares and initializes an array Fills the array with 10 random integers Adds every other number starting with the first element How should you complete the code? To answer, select the appropriate…
To complete the code according to the requirements, the following selections should be made: For var numbers =, select [0,0,0]. For numbers., select push. For var sum = 0;, select for. For j+=, select j+2. (Note: In standard JavaScript, this would typically be j += 2 for…
Implementing Flow Control
Question
Declares and initializes an array
Fills the array with 10 random integers
Adds every other number starting with the first element
How should you complete the code? To answer, select the appropriate code segments in the answer area.
NOTE: Each correct selection is worth one point.
Explanation
To complete the code according to the requirements, the following selections should be made:
- For
var numbers =, select[0,0,0]. - For
numbers., selectpush. - For
var sum = 0;, selectfor. - For
j+=, selectj+2. (Note: In standard JavaScript, this would typically bej += 2for incrementing by 2). - For
sum +=, selectnumbers[j].
Topics
#arrays#Math.random#loops#iteration
Community Discussion
No community discussion yet for this question.