I'm building a calculator that takes 2 values from 2 input fields and runs a function for the calculation. The numbers that will be entered will be to 2 decimal places as they are prices. For example 35.84.
The results I'm getting are whole numbers and doesn't include the 2 decimal places. For example, if I enter 60 for (gas) and 34.84 for (price) my result is 17.00 and not 17.84
What am I doing wrong?
Thanks
const calculate = document.getElementById('one');
calculate.addEventListener('click', calc);
function calc() {
event.preventDefault();
let gas = parseInt(document.getElementById('gas').value);
let price = parseInt(document.getElementById('price').value);
let gasSaving;
let result;
gasSaving = gas * 0.3;
result = price - gasSaving;
console.log(result.toFixed(2));
}