How to use forEach method?

Hey @sobadrdb,

In both functions you are using return to end the function, but here’s the thing, inside .forEach() is a function, so everything inside the foreach is just an anonymous function (function that doesn’t have a name).

So a return statement, will only end the .forEach() function not the main checkIn() function like how in your for loop the return statement will end the whole process.

image
In the image above, using the for loop and the return statement will END the whole function. But if you use .forEach():

image

It will not end the whole function, just the anonymous function inside the .forEach() loop.

Hope this clarifies your question. :slight_smile:

If you still need help, don’t be afraid to ask…

Anyways, Happy coding!!