Bootcamp
Search…
1.ICE.3: setInterval
Read this code. What order is the the console.logs going to be printed in?
1
const wowParagraph = document.createElement('p');
2
wowParagraph.innerText = 'Click Me!!';
3
document.body.appendChild(wowParagraph);
4
​
5
console.log('1');
6
​
7
const doLater = () => {
8
console.log('2');
9
wowParagraph.innerText = `cool! ${Math.random()}`;
10
};
11
​
12
console.log('3');
13
​
14
const myNewMain = (event) => {
15
console.log('4');
16
​
17
// setTimeout has been replaced with setInterval from the previous ICE
18
setInterval(doLater, 1000);
19
};
20
console.log('5');
21
​
22
wowParagraph.addEventListener('click', myNewMain);
23
console.log('6');
Copied!
Copy link