The snippet of code shown below continuously outputs the number 10. How can I modify it to display the sequence: 0 1 2 3 4 5 6 7 8 9
Below is the code in question:
function go() {
var procedures = [];
for (var i = 0; i < 10; i++) {
procedures[procedures.length] = function () {
alert("You are now " + i + " years old");
};
}
run_procs(procedures);
}
function run_procs(procs) {
for (var i = 0; i < procs.length; i++) {
procs[i]();
}
}
go();
I would appreciate some guidance on how to achieve the desired output. Thank you!