Fork and Clone this repo
- Create a
index.js
file. - This is a solo assignment. Be sure to work through these problems on your own.
You have an array called numbers with three elements: [1, 2, 3]. Destructure the array into three separate variables: first, second, and third, and assign the corresponding values. Print the value of second.
Consider the following object:
const person = {
name: 'John',
age: 30,
city: 'New York'
};
Using destructuring, extract the values of name and city from the person object and store them in variables called personName
and personCity
, respectively. Print the values of both variables.
You have an object called car with the following properties:
const car = {
brand: 'Toyota',
model: 'Corolla',
year: 2022
};
Use Object.keys
to extract the keys of the car object into an array called keysArray
. Print the keysArray
.
Using Object.values
, extract the values from the car object defined in the previous problem and store them in an array called valuesArray
. Print the valuesArray
.
Using Object.entries
, extract both the keys and values from the car object defined earlier and store them in an array called entriesArray
. Print the entriesArray
.