'map then forEach returning expected assignment or function call React

I have a function that is mapping then running a forEach to return a result. this function works fine in a plain js html file. but in React im getting the expected assignment or function call error

Here is the code

const customContactValues = fiftyContacts?.map((contact) => { 
    let result = {};
  // this line is giving error  
mentionReformat?.forEach((mention) => { result[mention.name] = valueByKey(contact, mention.name) } ); return result
});


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source