Эффект пишущей машинки JavaScript

// this function performs a typewriter effect on an element from the HTML DOM
function TypeWriter(target, text, delay, clearText = false) {
	if (element.textContent === text) {
		return;
	}
	if (clearText) {
		element.textContent = "";
	}
	let _delay = 0;
	for (let i = 0; i < text.length; i++) {
		_delay += delay;
		window.setTimeout(function() {
			target.textContent += text[i];
		}, _delay);
	}
}
MattDESTROYER