I'm trying to create a "synchronized like loop" with async await but I get the strange behavior of getting all the results after the first promise instead.
here is my test case. See how you get all together instead of print 1 by 1
const p = () => new Promise((resolve) =>{
setTimeout(()=>{
resolve(Math.floor(Date.now() / 1000))
},1000)
})
const test = () =>{
[1,2,3,4,5,6,7,8,9,10].map(async () =>{
const e = await p();
console.log(e)
});
}
test();