Who can tell me why the timer doesn't work after setting the conditions?

Code:

function setCoin () {

let coins = 999000;
let z = document.getElementById("coinAmount");
let t = setInterval(() => {
  if (coins > 1000000) {
    coins = 1000000;
    clearInterval(t);
  } else {
    let c = Math.floor(Math.random() * 10 );
    coins += c;
    z.innerHTML = coins;
  }
}, 10);

}
Why coins = 1000000; this line of code doesn"t work.
clipboard.png

May.25,2021

let t = setInterval(() => {
  if (coins > 1000000) {
    coins = 1000000;
    clearInterval(t);
  } else {
    let c = Math.floor(Math.random() * 10 );
    coins += c;
  }
  z.innerHTML = coins; //  if 
}, 10);

you just assigned
z.innerHTML = coins;


in js , and the timer ends


.

let coins = 999000;
let z = document.getElementById ('coinAmount');
let t = setInterval (() = > {
if (coins > 1000000) {

coins = 1000000;
clearInterval(t);

} else {

let c = Math.floor(Math.random() * 10 );
coins += c;(c1000000)
z.innerHTML = coins;

}
}, 10);

Menu