I've been working on a script to create an animated "self-writing text" effect. However, I'm encountering an issue where each word jumps to the next one instead of smoothly transitioning by deleting each letter before moving on to the next word in the array.
const text = ['design', 'make', 'develop', 'code', 'create']
let count = 0;
let index = 0;
let currentText = "";
let letter = "";
(function type() {
if (count === text.length) {
count = 0;
}
currentText = text[count];
letter = currentText.slice(0, ++index);
document.querySelector(".main__animation").textContent = letter;
if (letter.length === currentText.length) {
count++
index = 0;
}
setTimeout(type, 500);
}())
Any help or suggestions would be greatly appreciated!