我想在while循环中添加延迟/睡眠:
我是这样试的:
alert('hi');
for(var start = 1; start < 10; start++) {
  setTimeout(function () {
    alert('hello');
  }, 3000);
}
只有第一种情况是正确的:显示后alert('hi'),它会等待 3 秒然后alert('hello')会显示,然后alert('hello')会不断重复。
我想要的是 afteralert('hello')显示 3 秒后alert('hi'),第二次需要等待 3 秒alert('hello'),依此类推。