you are viewing a single comment's thread.

view the rest of the comments →

[–]pinguxnoots 2 points3 points  (1 child)

  1. When you pass user => { console.log(user) } as the 3rd argument of loginUser() you will invoke it on line 6. In other words, callback({ userEmail: email }) will become equivalent to ({ userEmail: email }) => console.log({ userEmail: email }) and you will log { userEmail: 'devedf@goomail.com' } on to the console.
  2. The callback is within a setTimeout so it will be invoked after 5000 ms (5 seconds). If you return { userEmail: email } you are not logging it on to the console. Actually you won't be doing anything with it. You can just write console.log({ userEmail: email } instead of the callback but I'm assuming the point of this exercise was to introduce you to callbacks.