1document.addEventListener('DOMContentLoaded', function() {
2
3 showText("#msg", "Hello, World!", 0, 100);
4
5});
6
7let showText = function (target, message, index, interval) {
8 if (index < message.length) {
9 document.querySelector(target).innerHTML =
10 document.querySelector(target).innerHTML + message[index++];
11 setTimeout(function () { showText(target, message, index, interval); }, interval);
12 }
13}