map関数の実装
code:map.js
function myMap(val, low1, high1, low2, high2){
return (low1 == high1)? null : ((val - low1) / (high1 - low1) * (high2 - low2) + low2);
}
var result = myMap(-5, 0, 10, 100, 200);
$('<h2>').text(result).appendTo($('body'))
クリックで実行