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)}.`
});
Top comments (0)