DEV Community

Cover image for Great tutorial by @nsebhastian on .map()
Realised-Prophets
Realised-Prophets

Posted on

1

Great tutorial by @nsebhastian on .map()

I really enjoyed this tutorial:

https://www.freecodecamp.org/news/javascript-map-how-to-use-the-js-map-function-array-method/

I especially appreciate the final video which goes into detail about the syntax and different arguments you can give the .map() method.

Spoiler! Here's my solution to the final challenge in the third video.

let bio = completeUserData.map(function(element, index, array) {
    return `"${index + 1}. ${element.firstName} is from ${element.additionalInfo.hometown}. 
    ${element.pronouns.main.capitalized} has a ${element.additionalInfo.pet.species} named 
    ${element.additionalInfo.pet.name}. ${element.pronouns.possessive.capitalized} favorite color is 
    ${element.additionalInfo.favoriteColor} and ${element.pronouns.possessive.lowerCase} favorite food is 
    ${element.additionalInfo.favoriteFood}. ${element.pronouns.possessive.capitalized} siblings are 
    ${element.additionalInfo.siblings.slice(0, -1).join(', ')} and ${element.additionalInfo.siblings.slice(-1)}.`
});

Enter fullscreen mode Exit fullscreen mode

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay