Giving Parameters Defaults
A quote’s first note starts its list, so that call leaves notes out. Python’s add_note() uses
the familiar idiom, notes=None and a fresh list inside, since a list default would be shared by
every call. The line-by-line port turns None into null and drops the =None, since a
JavaScript call can already leave any argument out:
function addNote(note, notes) {
if (notes === null) {
notes = [];
}
notes.push(note);
return notes;
}
console.log(addNote("rush job"));
It throws at the .push() line. Only the error line is shown:
TypeError: Cannot read properties of undefined (reading 'push')