Submitted at
2026-06-17 22:00:21
javascript
AI generated puzzle
class Patch {
constructor(bankLabel, patchName) {
this.bankLabel = bankLabel; // e.g. 'Bank A'
this.patchName = patchName; // e.g. 'Lush Pad'
this._displayName = undefined;
}
// Lazily builds 'Bank A · Lush Pad' and caches it on first read.
get displayName() {
if (this._displayName === undefined) {
this._displayName = `${this.bankLabel} · ${this.patchName}`;
}
return this._displayName;
}
}
function renderPatchList(patches) {
return patches.map((patch) => patch.displayName).join('\n');
}
function renameBank(patches, oldLabel, newLabel) {
for (const patch of patches) {
if (patch.bankLabel === oldLabel) {
patch.bankLabel = newLabel;
}
}
}
const bank = [
new Patch('Bank A', 'Lush Pad'),
new Patch('Bank A', 'Acid Bass'),
];
// UI renders the list first...
console.log(renderPatchList(bank));
// 'Bank A · Lush Pad\nBank A · Acid Bass'
// ...then the user renames the bank and we re-render.
renameBank(bank, 'Bank A', 'Bank B');
console.log(renderPatchList(bank));
// Expected: 'Bank B · Lush Pad\nBank B · Acid Bass'
// Actual: still shows 'Bank A · ...'