Thanks Mike for the correction. I have updated the post with your correction. Catching error by displaying the exact error message to the user or UI is not the best strategy sometimes. The error message from the code is meant for the developer so that the problem can be fixed. It is best to selectively catch errors by display user friendly message to your User Interface. The error might show some inner workings of your system that you won't want a user to ever see.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks, Jemie!
super()
should be called insideconstructor()
.throw new Error(`Invalid ingredients: ${ingredients}`)
Thanks Mike for the correction. I have updated the post with your correction. Catching error by displaying the exact error message to the user or UI is not the best strategy sometimes. The error message from the code is meant for the developer so that the problem can be fixed. It is best to selectively catch errors by display user friendly message to your User Interface. The error might show some inner workings of your system that you won't want a user to ever see.