Your question is Predict Code Output and Errors. Take a moment with it on the right.
Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).
A teammate wrote the function below to schedule a batch of user notifications and log the results once they're all done.
function scheduleNotifications(users) {
const results = [];
for (var i = 0; i < users.length; i++) {
setTimeout(function () {
results.push("Notifying " + users[i].name + " (index " + i + ")");
}, 0);
}
console.log("Scheduling done for", users.length, "users");
setTimeout(() => console.log(results), 10);
}
scheduleNotifications([{ name: "Amara" }, { name: "Ben" }, { name: "Chen" }]);
Predict exactly what this program prints, in order, and identify every error it produces along the way. Then explain what you would change and why.