441 B
441 B
title, type, language, tags, cover, dateModified
| title | type | language | tags | cover | dateModified | |
|---|---|---|---|---|---|---|
| Map number to range | snippet | javascript |
|
carrots | 2020-10-21T21:54:53+03:00 |
Maps a number from one range to another range.
- Return
nummapped betweenoutMin-outMaxfrominMin-inMax.
const mapNumRange = (num, inMin, inMax, outMin, outMax) =>
((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
mapNumRange(5, 0, 10, 0, 100); // 50