function typeIt() { let counter = 0; teletype.innerHTML = cursor; teletype.removeAttribute("hidden"); let i = setInterval(function(){ teletype.innerHTML = telecopy.substr(0, counter) + cursor; counter++; if(counter === telecopy.length + 1) { clearInterval(i); } }, 100); } typeIt();