Skip to content

Instantly share code, notes, and snippets.

@codeBelt
Last active June 1, 2016 04:29
Show Gist options
  • Select an option

  • Save codeBelt/d9f05fe68964d20eb007 to your computer and use it in GitHub Desktop.

Select an option

Save codeBelt/d9f05fe68964d20eb007 to your computer and use it in GitHub Desktop.
Gets the value between min and max by percentage
var MAX = 150;
var MIN = 0;
var PERCENT = 0.5;
var value = ((MAX - MIN) * PERCENT) + MIN;
var percent = (value - MIN) / (MAX - MIN);
console.log(value); // 75
console.log(percent); // 0.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment