Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Template Literal Format

Data Structures, Operators & Stringseasy

Course · Section 9: Data Structures, Modern Operators and Strings · Lecture 111: The Spread Operator (...)

Implement `formatUser(user)` returning a string like `Ada (30)` from `user.name` and `user.age`, using a template literal.

Sample tests

Input: formatUser({"name":"Ada","age":30})
Output: "Ada (30)"
Input: formatUser({"name":"Bo","age":5})
Output: "Bo (5)"

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • String concatenation works but is noisier than a template literal.

Learning resources

  • MDN: Destructuring assignment
Approach & explanation (try first)

Template literals interpolate the name and age directly into the formatted string.

Loading...
⌘/Ctrl + Enter

Run your code to see results.