Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the following code: (Code has to do with JavaScript) var myArray = [1,2,3,

ID: 3685334 • Letter: G

Question

Given the following code: (Code has to do with JavaScript)

var myArray = [1,2,3,4,5,6];

function someFunc(array)   {

   var s = 0;

   for (var i = 0; i < array.length; i++) {

   s = s + array [ i ];

   }

   return (s / array.length);

}

var a = someFunc (myArray);

What will variable a's value be after the code is finished? What is the purpose of the function someFunc?

A. Value: 4

    The factorial value of all myArray's numbers

B. Value: 3.5

    The average value of all numbers in myArray

C. Value: NaN

    It doesn't do anything

D. Value: 21

    Is the sum of all values

E. Value: 3.5

     Some random number

Explanation / Answer

Bellow is the answer

B. Value: 3.5

The average value of all numbers in myArray

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote