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