num
mapped between outMin
-outMax
from inMin
-inMax
.const mapNumRange = (num, inMin, inMax, outMin, outMax) => ((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
mapNumRange(5, 0, 10, 0, 100); // 50
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️