Unresolved function or method forEach()

Terminal Error:

How can i fix this?

0
1 comment

You are using the wrong syntax. forEach() is a method of Array.prototype, it's not defined in Node.js global namespace.

the correct syntax is

const arr = [1,2,3,4,5,6];
arr.forEach((number) => console.log(number)
);
1

Please sign in to leave a comment.