let kunas = document.querySelector(`body`);
let spalvaLaik = async (spalv,laik) => setTimeout(() => {
kunas.style.backgroundColor = spalv;
}, laik);
await spalvaLaik("blue",1000)
await spalvaLaik("green",1000)
await spalvaLaik("yellow",1000)
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title></title>
</head>
<body>
<p>para</p>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
Hi I'm trying to make the await work but it keeps showing this error : Uncaught SyntaxError: await is only valid in async functions, async generators and modules
;
Is there something wrong here? Because Im pretty sure I declared the arrow function to be an async one. I tried other suggestions but none seems to work. Any help is appreciated. Thanks!