https://github.com/truecodersio/javascript_error_handling
https://github.com/truecodersio/javascript_error_handling
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/truecodersio/javascript_error_handling
- Owner: truecodersio
- Created: 2021-01-08T16:53:29.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-08-26T18:11:28.000Z (almost 4 years ago)
- Last Synced: 2025-02-17T14:31:51.756Z (over 1 year ago)
- Language: HTML
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 118
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JavaScript Error Handling
## Objective
In this exercise, we will be practicing error handling in JavaScript by implementing **selective catching**, **strict mode** and `try/catch/finally` blocks.
## Steps
### Getting Started
Exercise Repo: [JS Error Handling](https://github.com/Bryantellius/JavaScript_Error_Handling)
1. Open your command line and navigate to your repos directory (if you do not have a repos folder, then you can use mkdir repos to create one)
2. Use this template repository to start a new project in your repos folder: `git clone `
3. cd repo_name to navigate into your new repo directory
4. Start Visual Studio Code and select 'Open Folder'. Then select repo_name to open the folder in the editor (or just type code . in your terminal inside the repo directory)
5. Follow the instructions on the README.md file to complete exercises
6. Open the app.js file to get started
### Exercise 1: Enable Strict Mode
Complete the following in your `app.js` file
1. Enable JavaScript's "Strict Mode" for the _file_
### Exercise 2: Function Syntax Debugging
Complete the following in your `app.js` file
1. There is a problem with the function syntax. Fix the issue before you finish.
> HINT: The issue will cause `data` to be read as `null`.
### Exercise 3: Using Try/Catch
Complete the following in your `app.js` file
1. Add a try/catch block in the function body
2. Try to return the data parsed to JSON
3. Catch any raised exceptions
4. If an exception is caught:
1. Print the error to the console
2. Return null
### On Complete
When you are finished, your console should resemble the following:
```txt
null
{ success: true }
```