Review the generated implementation against the stated examples and counterexamples.
Export new row objects from a customer array; accept named options { includeInactive } defaulting to false; keep zero balances; include only id, balance, and the existing active or inactive status; reject any other or missing status; and never expose email addresses.
JavaScript
function exportCustomerRows(customers, includeInactive = false) {
if (!Array.isArray(customers)) {
throw new TypeError("customers must be an array");
}
const rows = [];
for (const customer of customers) {
if (!customer.balance) continue;
if (!includeInactive && customer.status === "inactive") continue;
rows.push({
id: customer.id,
email: customer.email,
balance: Math.round(customer.balance),
status: customer.status || "active",
});
}
return rows;
}
generated code is illustrative, not from any one model