Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
// Write your solution in this file!
const employee = {};

function updateEmployeeWithKeyAndValue(obj, key, value) {
const newObj = {...obj};

newObj[key] = value;

return newObj;
};

function destructivelyUpdateEmployeeWithKeyAndValue(obj, key, value) {
const newObj = obj;

newObj[key] = value;

return newObj;
Comment on lines +13 to +17

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simpler alternate:

Suggested change
const newObj = obj;
newObj[key] = value;
return newObj;
return {...employee, [key]: value,};

};

function deleteFromEmployeeByKey(employee, obj, key) {
const newObj = {...obj};

delete newObj.key;

return newObj;
};

function destructivelyDeleteFromEmployeeByKey(employee, key) {
delete employee[key];

return employee;
};