Skip to content

Instantly share code, notes, and snippets.

@mertcanekiz
Last active June 30, 2019 22:46
Show Gist options
  • Save mertcanekiz/54fcbe5a038e4964a610efa3b2fe65c0 to your computer and use it in GitHub Desktop.
Save mertcanekiz/54fcbe5a038e4964a610efa3b2fe65c0 to your computer and use it in GitHub Desktop.
function map(n, start1, stop1, start2, stop2) {
return ((n-start1)/(stop1-start1))*(stop2-start2)+start2;
}
function scovilleToLevel(scoville) {
let log = Math.log10(scoville);
return map(log, 0, 6, 1, 11); // 6 because Math.log10(1000000)=6
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment