I have a javascript and I don't know where excatly I should insert window.onload should I place it in the middle or before can any one guide me to the right placement ??
Javascript:
window.onload = function() {
const printSentence = (id, sentence, speed = 50) => {
let index = 0;
let element = document.getElementById(id);
let timer = setInterval(function() {
const char = sentence[index];
if (char === '<') {
index = sentence.indexOf('>', index); // skip to greater-than
}
element.innerHTML = sentence.slice(0, index);
if (++index === sentence.length) {
clearInterval(timer);
}
}, speed);
} // printSentence
printSentence(
'one',
'<p>hello</p>',
50
);
}