---
# System prepended metadata

title: Objects

---


# Objects

### Adding key/value pairs to objects

**1 - Fruit Basket**
Add the following fruits with their name as the key and their color as their value to the fruitBasket object.

```
banana : 'yellow'
avocado: 'green'
strawberry: 'red'
```

<iframe style="margin-bottom:8px;" height="600px" width="100%" src="https://repl.it/@thinkful/add-object-keys-js?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>

**2 - Drink Shop**
You recently setup a new drink stand, but need to add the products and price for each drink you sell. Add at least three products and their prices like this:

`soda: 3`

<iframe style="margin-bottom:8px;" height="600px" width="100%" src="https://repl.it/@thinkful/add-object-keys-js-1?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>


**3 - Programming Languages**
Add programming languages `'swift', 'javascript', and 'java'`with the key being the name of the programming language and what you think is the difficulty of learning it as it's value to the `languages` object. Example:
`'python' : 'easy'`

<iframe style="margin-bottom:8px;" height="600px" width="100%" src="https://repl.it/@thinkful/add-object-keys-js-3?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>

**4 - Web Stacks**
You are learning about some of the basic web development stacks that are commonly used in startup companies. Add the MEAN and LAMP web stacks to the techStacks object with the **name of the stack** as the key and the value being an **array of the technologies** used for the stack. Below is an example for the MERN stack.

NOTE: You will have to use Google to find out what the technologies are used in the MEAN and LAMP stack.

```javascript
MERN : ['MongoDB', 'ExpressJS', 'React', 'NodeJS']
```

<iframe style="margin-bottom:8px;" height="600px" width="100%" src="https://repl.it/@thinkful/add-object-keys-js-4?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>


**5 - Family Tree**
The tree below shows Joe's family tree. Recently one of Joe's children (allen) had a daughter, named karen. However, they are not showing up on the database for their family tree. Add `allen` and his daughter `karen` to the family tree. Below is an example for adding jose and his daughter under Joe's family tree:

```javascript
// adding Jose and his child to the family tree:
family = {
  'joe' : { ...
  }
}

// Add Joe's son, pedro and his daughter, jessica
family.joe.pedro = 'jessica'


// family tree after adding pedro and jessica
family = {
  'joe' : {
      'pedro' = 'jessica'
  }
}
```
<iframe style="margin-bottom:8px;" height="600px" width="100%" src="https://repl.it/@thinkful/add-object-keys-js-5?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>


### Removing key/value pairs

**6 - Movie**
The object below represents the data for the movie for Spiderman. However, someone hacked it and added an attribute that isn't supposed to be there. Can you guess which one it is?

Find and remove the `popcorn` attribute from `movie`.
If you forgot how to remove a key and it's value, [this link](#Deleting-keyvalue-pairs) will take you back to the notes about deleting key/value pairs.

<iframe style="margin-bottom:8px;" height="600px" width="100%" src="https://repl.it/@thinkful/del-object-keys-js?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>

**7 - Users**
There was a glitch in the system and it accidentally created another password for the `user2` while they were trying to sign up for an account. 

Find and remove `password1` located in`user2` from the user database.

<iframe style="margin-bottom:8px;" height="600px" width="100%" src="https://repl.it/@thinkful/del-object-keys-js-1?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>

### Updating key/value pairs from objects

**8 - Test Scores**
You don't want your parents to know that you missed an assignment, so you go ahead and hack your grades!

Find and change the test with the lowest score to 98!

<iframe style="margin-bottom:8px;" height="600px" width="100%" src="https://repl.it/@thinkful/change-object-keys-js?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>

**8 - Car Dealer**
You are working for a car dealer and updating the price of the 2019 toyota camry. The car dealer owner wants you to update the current price of that car. 

Find and update the `current` price and change it to `10,000` (integer).

<iframe style="margin-bottom:8px;" height="600px" width="100%" src="https://repl.it/@thinkful/change-object-keys-js-1?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>


**9 - Students**
You are working on the student roster for your high school and noticed that two students are switched up. In other words, the information for student Jacob should be Guillermo's, and vice versa

Change `jacob` with `guillermo`.

:::warning
Hint: create a temporary variable called `temp` that holds jacob's values. 
:::


<iframe style="margin-bottom:8px;" height="600px" width="100%" src="https://repl.it/@thinkful/change-object-keys-js-2?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe>


## Bonus Challenges!



