DEV Community

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

Posted on

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

Top comments (0)