Why isn't .value actually grabbing the value of the input

Hello,
for some reason, my input1,input2 and input3 variables are not selecting the values from the input boxes on the page and I have no idea why. I have looked at the code over and over again and I still can’t figure out what’s wrong.
Here’s the link to codepen
Thanks in advance!

https://codepen.io/VeljkoCukic/pen/poERNjz

You are grabbing those values off the DOM when that JS loads. The JS variables do not automatically update as you type in the input. (That would be data binding.) If you move those statements like:

let input1 = parseInt(document.getElementById("inp1").value)

inside the callback for the event handler, then they will get the data when the event handler is called.

1 Like

Thank you so much, it works!!