refactor mean-median-mode.js for extensibility