Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This throw Statement worksheet is part of the JavaScript Coding without HTML and CSS journey. Print it as a booklet?
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1throw new Error("Something broke"); | Athrow | |
| 2throw new Error("Bad age"); | BWrong - 'Error' must start with a capital E | |
| 3Creates and raises a custom error | CRaises an error describing an invalid age | |
| 4Can be caught by a matching catch block | Dtry { throw new Error("X"); } catch (e) { ... } | |
| 5Throw new Error("Bad"); | EWrong - 'throw' must be lowercase | |
| 6throw new error("Bad"); | FRaises a custom error and stops execution at that point |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
throw — Creates a custom error and immediately stops the current code from running further.throw new Error("Something broke");throw new Error("Invalid input");throw new Error("No data found");if (age < 0) {
throw new Error("Bad age");
}throw new Error("Out of range");