User Profile Formatter

Format nested user data into a smaller profile summary.

Start building, submit solution and get feedback from the community.
2Submit Solution
5 upvotes10 upvotes

User Profile Formatter

Format a nested user object into values that are easier to show in an interface or return from an API. The final summary should collect the smaller pieces.

Write these functions:

  • getDisplayName(user) should return the first and last name as one string.

  • getLocation(user) should return "City, Country".

  • getContactSummary(user) should return an object with email and phone.

  • isAccountActive(user) should return true when account.status is "active".

  • createProfileSummary(user) should return displayName, location, contact, active, and plan.

Sample checks:

js
const user = {  id: 42,  firstName: 'Ava',  lastName: 'Stone',  email: 'ava@example.com',  phone: null,  address: {    city: 'London',    country: 'UK',  },  account: {    status: 'active',    plan: 'pro',  },};console.log(createProfileSummary(user));console.log(getDisplayName(user));console.log(isAccountActive(user));console.log(getContactSummary(user));

Expected output:

txt
{ displayName: "Ava Stone", location: "London, UK", contact: { email: "ava@example.com", phone: null }, active: true, plan: "pro" }Ava Stonetrue{ email: "ava@example.com", phone: null }

Keep phone as null when the user has no phone number.

Join the Community

roadmap.sh is the most starred project on GitHub and is visited by hundreds of thousands of developers every month.

Rank  out of 28M!

361K

GitHub Stars

Star us on GitHub
Help us reach #1

+90k every month

+2.1M

Registered Users

Register yourself
Commit to your growth

+2k every month

49K

Discord Members

Join on Discord
Join the community

Roadmaps Best Practices Guides Videos FAQs YouTube

roadmap.sh by @kamrify

Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.

ThewNewStack

The top DevOps resource for Kubernetes, cloud-native computing, and large-scale development and deployment.