I am confused in using setTimeout and each Iterator I can rewrite the following so that the console is 5 seconds Output every name after the delay? Currently the code below prints all names after 5 seconds. I want to: 1) Wait 5 seconds, print Kevin 2) Wait for 5 seconds, then print the mike 3) Wait 5 seconds, then print You can create a variable named var ary = ['Kevin', 'Mike', 'Sally']; _ (Saw) .each (function (person) {setTimeout (function () {console.log (person);}, 5000);});
offset Timer, wait for 5 seconds more for each person, such as:
var ary = ['Kevin', 'Mike', 'Sally']; Var Offset = 0; _ (Saw) .each (function (person) {setTimeout (function () {console.log (person);}, 5000 + offset) offset + = 5000;});
No comments:
Post a Comment