I am trying to implement a function 'y()' that I want to run on a delayed loop.
Currently, I have been using "setInterval" to execute the function every 2 seconds. The setInterval functionality is triggered by calling the function 'z1()' through a button click. However, this approach doesn't seem to be effective.
Below is the code snippet:
Javascript:
var x = 0-1;
var i;
function z1() {
setInterval(
function y() {
function number_string() {
x += 1;
document.getElementById("display").innerHTML = x;
var number = 1234567890123456789;
var one = String(number).charAt(x);
var one_as_number = Number(one);
document.getElementById("display2").innerHTML = one_as_number;
}
},2000
);
}
HTML:
<button onclick="z1()">x</button>