From ca7606dec38ac26c12665fe30693db6c0d28aead Mon Sep 17 00:00:00 2001 From: Yearim Yi Date: Fri, 23 Apr 2021 20:34:40 +0000 Subject: [PATCH 1/2] Done. --- index.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/index.js b/index.js index e69de29bb..772ced8a1 100644 --- a/index.js +++ b/index.js @@ -0,0 +1,21 @@ +function updateObjectWithKeyAndValue(object, key, value) { + object[key] = value + return object +} + +function updateObjectWithKeyAndValue(object, key, value) { + return Object.assign({}, object, { [key]: value }) +} + +function destructivelyUpdateObjectWithKeyAndValue(object, key, value) { + object[key] = value + +} + +function deleteFromObjectByKey(object, key) { + +} + +function destructivelyDeleteFromObjectByKey(object, key) { + +} \ No newline at end of file From aa2ff657f82ba9263a8465b85aa8bf571c51dd3e Mon Sep 17 00:00:00 2001 From: Yearim Yi Date: Fri, 23 Apr 2021 21:08:45 +0000 Subject: [PATCH 2/2] Done. --- index.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 772ced8a1..8e20e7b24 100644 --- a/index.js +++ b/index.js @@ -1,21 +1,24 @@ -function updateObjectWithKeyAndValue(object, key, value) { - object[key] = value - return object -} - function updateObjectWithKeyAndValue(object, key, value) { return Object.assign({}, object, { [key]: value }) } function destructivelyUpdateObjectWithKeyAndValue(object, key, value) { - object[key] = value + object[key] = value + return object } + + function deleteFromObjectByKey(object, key) { - + var newObj = Object.assign({}, object) + delete newObj[key] + return newObj + } function destructivelyDeleteFromObjectByKey(object, key) { + delete object[key] + return object } \ No newline at end of file