我需要显示是否answer => 2.80
var panel;
if (routeNodes.length > 0 && (panel = document.getElementById('distance')))
{
panel.innerHTML = Number((dist/1609.344).toFixed(1)).toFixed(2)
+ " miles = £"
+ Number((((dist/1609.344 - 1) * 1.20) + 2.80).toFixed(1)).toFixed(2);
}
如果< 2.80然后显示2.80
答案 0 :(得分:0)
var var1 = 10;
var var2 = 5;
var minimum = Math.min( var1, var2 );
var maximum = Math.max( var1, var2 );
// minimum now equals 5;
// maximum now equals 10;
答案 1 :(得分:0)
Ue的功能不是直接向innerHTML添加输出。
function getDistance(input, minimum) {
var miles = f(input);
return Math.max(miles, minimum);
}
var string = getDistance(someValue, 2.80) + ' miles -- ' + getDistance(someValue, 2.80)
panel.innerHTML = string;