The next method that we'll learn about is console.error. This method is useful for letting the user or a developer (whether that's you or someone else) know that an error has occurred.

All the same functionality that we learned about with log, info, and warn applies here. However, the most useful way to use console.error is by using the new Error() object. This will log more information, called a stack trace, to the console. That tells you in what file and on what line the error occurred. It's much more useful when trying to figure out why the error occurred and how to fix it.

For the exercise in this section, create 2 new Errors:

  1. Print an error saying that a pizza for your party has burned
  2. Print an error saying that one of the pizzas ran out

After you've finished, continue on to the next video.


I finished! On to the next chapter