I know that there were a lot of topics like this. And I know the basics: .forEach()
operates on original array and .map()
on the new one.
I
The main difference that you need to know is .map()
returns a new array while .forEach()
doesn't. That is why you see that difference in the output. .forEach()
just operates on every value in the array.
Read up:
You might also want to check out: - Array.prototype.every() - JavaScript | MDN