Reputation: 3224
i have this if statement:
if (price % 10 > 5) {
newPrice = floor(price / 10) * 10 + 9.95;
} elseif (price % 10 <= 5) {
newPrice = floor(price / 10) * 10 + 5.95;
}
Do i use parseInt
on 5.95? This works in PHP but i'm converting to JQuery and wondering if i have to make any changes?
I tried this with no luck
if (selectprice % 10 > 5) {
selectprice = parseFloat(floor(selectprice / 10)) * parseInt(10) + parseFloat(9.95);
} elseif (selectprice % 10 <= 5) {
selectprice = parseFloat(floor(selectprice / 10)) * parseInt(10) + parseFloat(5.95);
}
Upvotes: 0
Views: 45
Reputation: 331
Use Math.floor() instead of floor(). I don't think you need to make any other changes.
if (selectprice % 10 > 5) {
selectprice = Math.floor(selectprice / 10) * 10 + 9.95;
} else if (selectprice % 10 <= 5) {
selectprice = Math.floor(selectprice / 10) * 10 + 5.95;
}
Upvotes: 1