I am trying to get the function destructivelyDeleteEmployeeByKey(employee, key) to return employee without the deleted key/value pair that would modify the original employee
this is what itsays in the test.js file
describe('destructivelyDeleteFromEmployeeByKey(employee, key)', function () {
it('returns employee without the deleted key/value pair', function () {
let newEmployee = destructivelyDeleteFromEmployeeByKey(employee, 'name');
expect(newEmployee['name']).to.equal(undefined);
});
it('modifies the original employee', function () {
let newEmployee = destructivelyDeleteFromEmployeeByKey(employee, 'name');
expect(employee['name']).to.equal(undefined);
expect(employee).to.equal(newEmployee);
});
});
how do I write this function?
Did you meeam something like that? I think it should work
const destructivelyDeleteFromEmployeeByKey = (employee, key) => {
delete employee[key]
return employee
}