Skip to content
Open
Show file tree
Hide file tree
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
35 changes: 34 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
// Write your solution in this file!
const employee = {
name: "John Doe",
streetAddress: "123 Main St",
};

function updateEmployeeWithKeyAndValue(employee, key, value) {
return {
...employee,
[key]: value,
};
}

function destructivelyUpdateEmployeeWithKeyAndValue(employee, key, value) {
employee[key] = value;
return employee;
}

function deleteFromEmployeeByKey(employee, key) {
const newEmployee = { ...employee };
delete newEmployee[key];
return newEmployee;
}

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

module.exports = {
updateEmployeeWithKeyAndValue,
destructivelyUpdateEmployeeWithKeyAndValue,
deleteFromEmployeeByKey,
destructivelyDeleteFromEmployeeByKey,
};
Loading