var i = 0;var txt = ‘Blablablabla’;var speed = 50;
function typeWriter() {if (i < txt.length) {document.getElementById(“demo”).innerHTML += txt.charAt(i);i++;setTimeout(typeWriter,speed);}}
Can you explain this code step by step.
thesetimeout() function is the one that I still dont get.
Answer
Please find theupdated solution:(with explanation) and output
<!DOCTYPE html><html><head><title>Page Title</title> <script type=”text/javascript”> //temp variable i to store the length of txt var i = 0; //text to append to demo var txt = ‘Blablablabla’; // speed in millisecs var
OR
OR