I have a piece of code that has a text with an id, a button with a function to go to JavaScript to add a number every 10 seconds my problem is instead of adding 1 number it multiplies by 2
This is what I tried
function autoclick() {
var x = Math.floor((Math.random() + 1) + 0, ),
el = document.getElementById('test'),
val = parseInt(el.innerHTML, 10);
el.innerHTML = val + x;
var t = setInterval(autoclick, 1000);
}
<p id="test">0</p>
<button onclick="autoclick()">autoclick</button>