Skip to content

Instantly share code, notes, and snippets.

@bayleedev
Last active May 26, 2016 06:24
Show Gist options
  • Save bayleedev/008c7e95095e147ef539af448c5a5fac to your computer and use it in GitHub Desktop.
Save bayleedev/008c7e95095e147ef539af448c5a5fac to your computer and use it in GitHub Desktop.
var val = 5184;
var set = [7921, 5184, 8836, 4761]
var average = set.reduce((memo, num) => {
return memo + num;
}, 0) / set.length;
var max = Math.max.apply(this, set);
var min = Math.min.apply(this, set);
output = (val - average) / (max - min) // equation
rounded = Math.round(output * 100)/100 // rounds to nearest 100th place. (1.23456 => 1.23)
console.log(output)
console.log(rounded)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment