Objects

Destructuring Defaults

Destructuring Defaults

Object destructuring pulls named properties into local variables. A default value fills in only when the property is missing or has the value undefined.

This keeps formatting code readable when an API record has optional fields.

Your task: Write formatTicket(ticket) so it returns a string containing the ticket id, owner, and priority. If priority is missing, use "normal". Return the string from the function.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Destructuring Defaults

Object destructuring pulls named properties into local variables. A default value fills in only when the property is missing or has the value undefined.

This keeps formatting code readable when an API record has optional fields.

Your task: Write formatTicket(ticket) so it returns a string containing the ticket id, owner, and priority. If priority is missing, use "normal". Return the string from the function.

Free with a JS Exercises account

Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.

By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.

Console

Run code to see output.