I wanted to change the body background color to red first, and then to blue. But it's skipping the red. Got it from Colt Steele's The Web Developer Bootcamp.
function changeBG(color, delay) {
setTimeout(() => {
document.body.style.backgroundColor = color;
}, delay);
}
async function init() {
await changeBG('red', 1000);
await changeBG('blue', 1000);
}
init();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Title</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>