I have made a compounding calculator function and I am unable to apply toFixed() to it. What I basically want to do is apply toFixed(2) in order to get just two digits after the decimal. Here comes the code thank you very much in advance.
const compound = function () {
const value1 = document.getElementById("value1").value;
const value2 = document.getElementById("value2").value;
const value3 = document.getElementById("value3").value;
const compResult = document.querySelector(".result").innerHTML =
value1 * value2 ** value3;
return compResult.toFixed(2);
};
const calcButton = document.querySelector(".calculate");
calcButton.addEventListener("click", () => {
compound();
});