I trying to alert sum of 2 numbers from inputs but problem is that i cannot convert it into number type. Instead of this i getting NaN. Snippet:
var ipt1 = document.getElementById("w1").value;
var ipt2 = document.getElementById("w2").value;
function add(){
let l1 = parseInt(ipt1)
let l2 = parseInt(ipt2)
alert( l1 + l2 )
}
<body>
<input type="" id="w1"><br>
<input type="" id="w2"><br>
<input type="submit" value="dodaj" onclick="add()">
</body>