set15

Render n CSV rows by string concatenation

15 / 26
read the snippet · pick its Big-O
// Looks O(n) but isn't — the gotcha is string concat itself.
function toCsv(rows) {
let out = '';
for (const r of rows) {
out += r.id + ',' + r.name + '\n';
}
return out;
}