diff --git a/curriculum/challenges/english/blocks/lecture-debugging-techniques/6733bee844600f35c05b8264.md b/curriculum/challenges/english/blocks/lecture-debugging-techniques/6733bee844600f35c05b8264.md index 914ab753cf0..0e13f39b70b 100644 --- a/curriculum/challenges/english/blocks/lecture-debugging-techniques/6733bee844600f35c05b8264.md +++ b/curriculum/challenges/english/blocks/lecture-debugging-techniques/6733bee844600f35c05b8264.md @@ -5,7 +5,7 @@ challengeType: 19 dashedName: how-does-try-catch-finally-work --- -# --description-- +# --interactive-- In the previous lesson, you learned how to throw exceptions in your programs. In this lesson, we will take a look at how to gracefully handle these errors in a `try…catch…finally` block. @@ -17,6 +17,8 @@ The `finally` block runs after the `try` and `catch` blocks, regardless of wheth Here is an example of using a `try…catch` block: +:::interactive_editor + ```js function processInput(input) { if (typeof input !== "string") { @@ -35,6 +37,8 @@ try { } ``` +::: + In this example, we have a function called `processInput` that first checks if the `input` is not of type `string`. If that is the case, then we throw an error. Otherwise, we return the result of using the `toUpperCase` method on the `input`. We call the function inside of a `try` block. Since the function call throws an error, then it will be caught inside the `catch` block and the error message will be displayed in the console.