max-mapper / callback-hell

information about async javascript programming
http://callbackhell.com
847 stars 100 forks source link

Illegal return statement #36

Open ViavaCos opened 3 years ago

ViavaCos commented 3 years ago

I think you should not write code as below:

if (err) return statusMessage.value = err

There will throw some error like: Uncaught SyntaxError: Illegal return statement

File Path: callback-hell/index.html

seyerman commented 2 years ago

Then, how should be written this code?

ViavaCos commented 2 years ago

We cannot return a assignment, if you do and you will get an error as above. So, you just need change returns as below.

if (err) {
  statusMessage.value = err
  return statusMessage.value
}