Manipulating Objects
Learning Competencies
- Define local variables in JavaScript
- Create, add properties to, delete properties from, and access values from JavaScript Object literals
- Use pre-written tests to drive development
Time Box
Activity | Time |
---|---|
Kata | 1.5 hours |
Reflect | 10 minutes |
Summary
In this challenge, you will work with the following JavaScript object that has been assigned to the variable terah
. You will have to complete each task without modifying the object itself. That means everything must be done outside of the curly braces.
const terah = {name: "Terah",age: 32,height: 172,hairColor: "brown",eyeColor: "brown",};
There is some jargon used in this kata, so here's a quick recap of an object's anatomy:

Pass the Tests
The steps below match the order of the tests you will need to complete. After completing each step, run your code to ensure that the next test passes.
Note that each step below should be its own line of code in sequential order (i.e. each step will build on any of your code before it).
Define a variable
adam
and use object literal notation to assign this variable the value of an object with no properties.Give the
adam
object a name key that has the value "Adam".Add a spouse key to
terah
and assign it the value ofadam
.Change the value of the
terah
age property to 33.Remove the eyeColor property from
terah
(hint: use thedelete
operator).Add a spouse key to the
adam
object and assign it the value ofterah
.Add a children key to
terah
and use object literal notation to assign this variable to an empty object.Add a
ben
property to the value of theterah
children property.ben
should be an object with the keyname
and the value "Ben".Add a
wilson
property to the value of theterah
children property.wilson
should be an object with the keyname
with the value "Wilson".Add a
felicia
property to the value of theterah
children property.felicia
should be an object with the keyname
with the value "Felicia".Add a children property to
adam
and assign it the value ofterah.children
.
Your final terah
object will be logged to the console when all the tests have passed.