I do not get the input value x to add to i in the for loop. What am I doing wrong?
<!DOCTYPE html>
<html>
<body>
<input id="inp" type="number" > </input>
<button type="button" onclick=myFunction() > click</button>
<p id="result" > </p>
<script>
function myFunction(){
var txt= "";
res = document.getElementById("result");
res.innerHTML="";
var x= document.getElementById("inp").value;
var i= 0;
for ( ; i < 20; i++) {
txt += "input" + i + "<br>";
i = i += x ;
}
res.innerHTML=txt;
console.log(txt += "input is " + (i+x) + "<br>");
console.log(i);
}
</script>
</body>
</html>