Formula is (val x 0.5) + 50 = result, but if result is greater then 200, then override result to 150
My if is
if (val > 200) {
result = 150
}
Formula is (val x 0.5) + 50 = result, but if result is greater then 200, then override result to 150
My if is
if (val > 200) {
result = 150
}
If you just need a function:
function doSomething(val)
{
var result = val *.5 + 50;
if ( result > 200 )
{
result = 150;
}
return result;
}
In one line I suppose it would be:
var result = (val*.5) + 50 > 200 ? 150 : (val*.5) + 50;
I'm assuming if val<= 200, the result will be the real result.
var result = (val * 0.5) +50;
result = result>200?150:result;