A simple Javascript that calculates the average value