I am trying to replace a forEach method with map() but i am getting a weird result in the console. I don’t know why the same result is printed 12 times.
what do you want your map to do?
map returns an array where each element is the element of the starting array changed via the callback
are you sure you really want to use map here?
the elements of the starting array are fed to the function argument of map, and map returns a new array where each element is changed by the function
your starting array has 12 elements, so your returned array has also 12 elements
what’s the output you want to get? Without knowing that there isn’t much I can suggest
this is too hard for me to grasp. i have seen something like that, but… maybe you could break it down a little bit more. If i take it the way i understand this pseudo-code, then i should be expecting undefined(s) in the console.
Okay i get that, but could you please explain to me why there are twelve objects. i really didn’t fully understand what @ilenia was explaining.
Now you are saying the same thing. But the way i think of it is that if this is so, then i should have undefined as part of the output. I need a little bit more explanation on how it returns the same number of elements, please.
… made a lot of sense here, but i didn’t get it well enough