function tax (price, percent) { return parseFloat((price*percent/100).toFixed(2)); } var randomItem = 9.85; var salesTax = 7.5; var total = randomItem + tax(randomItem, salesTax); console.log(total);
This is a program on how to calculate sales tax with javascript, because handling floats is a bit weird with javascript.