Automatic conversion from boolean to number in an arithmetic operation.
function finalPrice(price) { const vat = 1.1 + 0.3 * (price >= 1000); return (price * vat).toFixed(2); }
- function finalPrice(price) {
const vat = 0.1,lux = 0.3,luxThreshold = 1000;- const vat = 1.1 + 0.3 * (price >= 1000);
const multiplier = price >= luxThreshold ? 1+vat+lux : 1+vat;return (price * multiplier).toFixed(2);- return (price * vat).toFixed(2);
- }