Write a function in javascript that calculates the average element in a non-empty list. Solution function average(array) { var sum = 0; for( var i = 0; i < array.length; i++ ){ sum += parseInt( array[i]); //don\'t forget to add the base } var avg = sum/array.length; window.alert( \"The average of all the elements is: \" + avg); }.