i want this output 1,1,1,....
instead of 2,1
i want to run synchronously
//just wait 2 seconds
function s(callback){
setTimeout(() => {
callback()
}, 2000);
}
a=[2]
while (a.length!==0){
a.shift()
s(()=>{
a.push(2)
console.log('1');
})
}
console.log('2');