GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Need help!!! tried everything

I need to do a assignment for my computer science class which I have no idea how to do and below is pasted the instructions and the code to start the assignment. It would be really helpful if you could please do it and email it to me. 




/* Program To Find the maximum integer in an array of positive integers */

var array1 = [2,12,4,10,6,8];
var array2 = [1,3,15,5,7,9,11,13];
var array3 = [8];
var array4 = [20,18,16,14,12,10,8,6];
var array5 = [2,4,6,8,10,12,14];

/*declare function findMax which takes an array as its only parameter and returns the maximum integer in that array.  Algorithm:

Set a local variable currentMax to the first element in the array
Write a for loop from 0 to the length of the array
For each element in the array:
    test to see if the list element at the index of the loop counter is greater than currentMax 
    if it is, then set currentMax to the value of that array element.
After the loop ends, have the function return currentMax.

/* Set fill to black so text shows up on the screen.

Call findMax five times, once for each of the arrays above.
Print the result of each function call to the screen.


asked Jan 24, 2017 by sahil