setInterval vs clearInterval which is better to run a loop at a specified speed

var speed = 200,
  len = 0;
if (e in know) {
  function typing() {
    if (len < know[e].length) {
      if (len === know[e].length - 1) {
        t.innerHTML = know[e];
        g = d.getAttribute("data-bottom") ? d.getAttribute("data-bottom") : 0;
        if (parseInt(g) < ((d.scrollHeight - t.offsetTop) - p.clientHeight) + 10) d.scrollTo(0, d.scrollHeight);
        else alert("new message");
      }
      len++;
      setTimeout(typing, speed);
    }
  }
  typing();

setTimeout vs
setInterval code…

var setIn = setInterval(() => {
  if (len < know[e].length) {
    if (len === know[e].length - 1) {
      clearInterval(setIn);
      t.innerHTML = know[e];
      g = d.getAttribute("data-bottom") ? d.getAttribute("data-bottom") : 0;
      if (parseInt(g) < ((d.scrollHeight - t.offsetTop) - p.clientHeight) + 10) d.scrollTo(0, d.scrollHeight);
      else alert("new message");
    }
    len++;
  }
}, speed)

I’m trying to make a reply bot that starts typing after 1 seconds and that will reply back at the speed of the String.length and they both did the same thing but someone once told me using setTimeout is bad practice, but I need them to run that exact way. If there is another work around for it I’m open to all suggestions, Thanks in advance.