I am trying to refactor a ReactJS component by using a map function. Is it possible to use the map() function to update multiple objects, or the same object twice? I am getting a syntax error when trying to update the initData object as follows:
days.map(day => {
return (
initData[`${day}From`] = myStr.slice(0, 2)
initData[`${day}To`] = myStr.slice(5, 7)
);
});
Note that I need to use return() due to React. Note that this works with one object:
days.map(day => {
return (
initData[`${day}From`] = myStr.slice(0, 2)
);
});
initDatawhere you have defined ?'charachter. Have you tried to fix it?return()due to react?