Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal return statement #36

Open
ViavaCos opened this issue Sep 3, 2021 · 2 comments
Open

Illegal return statement #36

ViavaCos opened this issue Sep 3, 2021 · 2 comments

Comments

@ViavaCos
Copy link

ViavaCos commented Sep 3, 2021

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
Copy link

seyerman commented Feb 9, 2022

Then, how should be written this code?

@ViavaCos
Copy link
Author

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants