Find Max
Print the largest element in a given array.
function find_max(arr) { var max = arr[0]; //your code here return max } find_max([1,2,3,8,-3)]);
function find_max(arr) { var max = arr[0]; for (var i = 1; i < arr.length; i++) { if (arr[i] > max) { max = arr[i]; } } return max } find_max([1,2,3,8,-3)]);