Update Multiple Objects Using The Javascript Map() Function
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 s
Solution 1:
You're not updating day
itself and not modifying the days
array, so there's no point using map
. Just use a for
or forEach
loop.
days.forEach(day => {
initData[`${day}From`] = myStr.slice(0, 2)
initData[`${day}To`] = myStr.slice(5, 7)
});
Post a Comment for "Update Multiple Objects Using The Javascript Map() Function"