/u1_lab_ES6_practice

Get some practice in with the new tools we've picked up with ES6!

Primary LanguageJavaScript

ES6 Practice

Fear

Homework Overview

We'll get some practice in with the new tools we've picked up with ES6!

Getting Started

  • Fork and Clone
  • Put your answers to the questions in this readme in the solutions.js file

Part 1 - Spreading Out

  1. Define two arrays, evens and odds filled with even and odd numbers.
  2. Using the spread operator, make a new array numbers that contains all of the evens and odds.

Part 2 - Merging Objects

  1. Define an object faveFoods that has keys representing three of your favorite foods and the values should be the restaurant or locale where they are from.
  2. Now make another object and do the same thing but this time ask your neighbor what their three favorite foods are. Literally. Go next door and ask them (jk that might not be safe, just pretend you know your neighbor - her name is Janet. very kind. lets you know that it is your other neighbor that is the smoker, not her. ok, Janet, we believe you.).
  3. Using the spread operator, build a final object allFoods with the items from faveFoods and janetFaveFoods together.

Part 3 - Destructuring

  1. Define yourself in a javascript Object with three keys: name, age, and hometown.
  2. Use the destructuring syntax to extract all three keys into variables. Log all three variables.
  3. Now we are going to give you a pet. Use destructuring to do the following: 1) add a pet object to your person, 2) define three variables (age, breed, name) outside of the object and 3) add those variables to your pet.
  4. Log the most important thing about you: your pet's name.

Resources