const getCapitalizedInitials = (name) => name .trim() .split(" ") .forEach((name) => name.charAt(0)) .join("") .toUpperCase()
We’re treating forEach as if it returned an array, when it actually returns undefined. Instead, we want to use map, which works similar to forEach, but also creates and returns a new array.
const getCapitalizedInitials = (name) => name .trim() .split(" ") .map((name) => name.charAt(0)) .join("") .toUpperCase()