I have an array of object of this type:
[{id: "somethin%g", apple: "dfgdf efd"}, ...] I want to replace some special chars in values of key = id and not change anything else of the object.
So the example above, must be:
[{id: "something", apple: "dfgdf efd"}, ...] I try this function:
function removeSpecialCharacters(metadata) { const result = metadata.forEach(datum => { const cleanId = datum.id.replace(/[.|&;$%@%"<>+]/g, '') return { ...datum, id: cleanId } }) console.log(result) return result } I get result = undefined. Why?