JavaScript Objects Lab

Objectives

  1. Create an object
  2. Add key-value pairs to an object
  3. Replace values in an object
  4. Delete key-value pairs in an object

Instructions

Be sure to run the tests to get a feel for the types of problems this lab is asking you to solve. In particular, you'll need to define a recipes object and then apply certain updates (destructively and non-destructively) in various functions.

recipes

Good luck!

HINT: You might find deleteFromObjectByKey to be a bit hard to write non-destructively. Think about how we learned to use Object.assign. What happens if we do

var obj = { foo: 'bar' }

var newObj = Object.assign({}, obj)

newObj // { foo: 'bar' }

delete newObj.foo // true

newObj // {}

obj // { foo: 'bar' }

Hmmmmm...

Resources