30 seconds of code

  Back to Home

mapNumRange

mathbeginner

Maps a number from one range to another range.

Returns num mapped between outMin-outMax from inMin-inMax.

const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
  ((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;