Here is what I'm trying to achieve:
console.log("Line at the start");
sleepFunction(5000);
console.log("Line printed after 5 seconds");
Output:
Line at the start
<waits for 5 seconds>
Line printed after 5 seconds
Is there any function like this? I've tried to use setInterval but the line printed after 5 seconds appears first, then it waits for 5 seconds.