why array foreach settimeout javascript doesn't cause delay but execute at the same time code example
Example: adding delay in javascript foreach loop
// tasks is your array
tasks.forEach((element,i) => {
setTimeout(
function(){
//the work you want to perform
}
, i * 300);
});