Exercise 2: Destructuring

Test your understanding of destructing in this lesson.

Problem statement

Let’s work through a small challenge to practice function implementation using object destructing. In this exercise, we will use destructuring on parameters to implement the getDetails() function.

Sample input and output

The input function call and respective output are given below.

Input

The input given below will help you decide the getDetails() function’s number and type of parameters.

getDetails({name: 'Sara',
    born: { month: 1, day: 1, year: 2000 },
    graduated: { month: 5, day: 31, year: 2018 }});

Output

The output will be:

Sara born in the year 2000, graduated in 2018.

Exercise

Let’s complete this challenge to get the desired output. The solution to this challenge is available in the next lesson, but you should try it yourself first.

Get hands-on with 1400+ tech skills courses.