Challenge: Destructure Undefined

This challenge will require you to destructure "undefined" in JavaScript.

Problem statement #

The function pointValues takes the parameter point, which is an object with a name and age property.

var point = {name: "jerry", age: 2}

The function extracts and displays the values of name and age. This function works when point is defined.

However, when point is undefined, the code runs into an error.

When you run the code below, you’ll see that it displays the name and age values when point is defined but throws an error for an undefined value of point.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.