Your question is JavaScript Output From Code. 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).
ValueMomentum builds policy administration software for insurers. A developer wrote the snippet below to build one premium calculator per pricing tier and log each tier's premium on demand. During code review, a teammate ran it and got a result nobody expected.
function buildPremiumCalculators(count, basePremium) {
const calculators = [];
for (var i = 0; i < count; i++) {
calculators.push(function () {
console.log(`Tier ${i}: premium=${basePremium + i * 10}`);
});
}
return calculators;
}
const calcs = buildPremiumCalculators(3, 200);
calcs[0]();
calcs[1]();
calcs[2]();
Tell me the output of this JavaScript code snippet, in order, and explain exactly why each line prints what it does.