Why do people complicate things so?
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Functions</h1>
<p>Call a function which performs a calculation and returns the result:</p>
<p id="demo"></p>
<script>
function calculateTax(cost, tax) {
console.log(cost * tax);
return(cost * tax);
}
let result = calculateTax(1000, 0.5);
document.getElementById("demo").innerHTML = result;
</script>
</body>
</html>
(Sandbox from w3schools: W3Schools Tryit Editor[^] )