Skip to content

Instantly share code, notes, and snippets.

@SankaitLaroiya
Last active March 9, 2018 21:54
Embed
What would you like to do?
(JS) Scale Numbers Between a Given Range
// Code snippet taken from:
// https://stackoverflow.com/a/31687097
function scaleBetween(unscaledNum, minAllowed, maxAllowed, min, max) {
return (maxAllowed - minAllowed) * (unscaledNum - min) / (max - min) + minAllowed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment