add findAverage feature to JS