JSFiddle - React, Tailwind, and code Playground
JavaScript
var text = new Array();
text[0] = "welcome ".split('');
text[1] = "how are u?".split('');
function printLetter(phrase_index, letter_index) {
var word = text[phrase_index];
if (word) {
if (letter_index === word.length) {
printLetter(phrase_index + 1, 0);
} else {
var letter = word[letter_index];
if (letter) {
$('body').append('<br />' + letter);
setTimeout(function () {
printLetter(phrase_index, letter_index + 1);
}, 200);
}
}
}
}
printLetter(0, 0);