var mapRange = function(from, to, s) { return to[0] + (s - from[0]) * (to[1] - to[0]) / (from[1] - from[0]); }; console.log(mapRange([1700, 6500], [1900, 10091], 1700));