I'm lost working on a computer science assignment and my teacher isn't available to help. I have a simple JS program that's supposed to subtract values from user input.
Here is my code:
document.getElementById("calculateButton").addEventListener("click", calculate);
function calculate(){
var exspendin = document.getElementById('exspendin');
var avfundin = document.getElementById('avfundin');
var total = 'exspendin' - 'avfundin';
//var total = math.subtract('avfundin', 'exspendin')
document.getElementById('calc');
window.alert('total');
}
<div><input type="text" id="avfundin" height="79" width="328" y="153.5" x="235.99999" value="Input Available Funds"><div>
<div><input type="text" id="exspendin" height="79" width="328" y="292.5" x="235.99999" value="Input Expected Spending"><div>
<a id="calculateButton">Calculate</a>
When I run, it prints "total" instead of the difference of the user input.
How would I get it to do that?
window.alert(total)without', but still, I never sawxandyin an input textvar total = 'exspendin' - 'avfundin'should bevar total = +exspendin- +avfundin