Search min, max number and avg using Javascript