I'm new in this thing and I don't understand why is happening. According to internet setTimeout function is supposed to run my code after the milliseconds that I choose, and it works, but why when I put it inside a for loop it just wait for once? How can I solve it? tnks
for (let i = 0; i < 5; i++) {
setTimeout(function(){
console.log(i);
},1000)
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="js/main.js"></script>
</body>
</html>