loop that console logs every item of the array one by one, but I want to delay the messages (1 second in between messages) how do I do that?
SetTimeOut
for (let i = 0; i < arr.length; i++) { setTimeout(function () { console.log(arr[i]); }, 1000 * i); }
const sleep = duration => { return new Promise ( resolve => { setTimeout(resolve, duration) }) } await sleep(1000)
Обсуждают сегодня