Javascript CodeEval Solution