diff --git a/index.js b/index.js index e69de29bb2..7fcafc575a 100644 --- a/index.js +++ b/index.js @@ -0,0 +1,25 @@ +var recipes = {cake:"eggs", bread: "flour"} + +function updateObjectWithKeyAndValue(object, key, value) { + var newObject = Object.assign({}, object, {[key]: value}) + return newObject +} + +function destructivelyUpdateObjectWithKeyAndValue(object, key, value) { + object[key] = value + return object +} + +function deleteFromObjectByKey(object, key) { + var newObject = Object.assign({}, object) + delete newObject[key] + return newObject + +} + +function destructivelyDeleteFromObjectByKey(object, key) { + delete object[key] + return object +} + +console.log(updateObjectWithKeyAndValue(recipes, 'soup', "water")) \ No newline at end of file