I’m trying to create an edit
function in Item
that will take a parameter of the key (sorry if I get the terminology wrong, but something like: title
) and replace its value with the second parameter. Here is my code so far:
class Item { constructor(title, description, date, done = false) { this.title = title; this.description = description; this.date = date; this.done = done;
}
edit(property, newValue) { Do something here.
} }
const dentist = new Item("Dentist appointment", "With Sally", "19/06/2024") dentist.edit(title, "Appointment") // May need to pass something else in. console.log(dentist)
New contributor
Monnt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.