mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat(curriculum): create debugging quiz (#56429)
Co-authored-by: Naomi the Technomancer <accounts+github@nhcarrigan.com>
This commit is contained in:
+100
-100
@@ -17,439 +17,439 @@ Answer all of the questions below correctly to pass the quiz.
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What type of error occurs when a variable is used before it is defined?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Syntax error
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Logical error
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Range error
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Reference error
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which JavaScript statement can be used to intentionally pause the execution of your code for debugging purposes?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`try...catch`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`console.log()`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`alert()`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`debugger`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which console method can be used to display data as a table?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`console.log()`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`console.warn()`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`console.error()`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`console.table()`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following errors does `try...catch` handle?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Syntax errors
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Infinite loops
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Logical errors
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Runtime errors
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is the correct syntax for using `try...catch` in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`try { ... } else { ... }`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`try { ... } catch { ... } finally { ... }`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`try { ... } error { ... }`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`try { ... } catch(error) { ... }`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following is a logical error?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Using `const` instead of `let`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Calling a function that doesn't exist
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Writing `==` instead of `===`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Incorrectly calculating a sum
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is the purpose of breakpoints in JavaScript debugging?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Automatically correct code mistakes
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Prevent code from being executed
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Log messages to the console
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Pause execution at a specific point
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What happens when the `throw` statement is executed?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
The code after `throw` continues running
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
It triggers the `finally` block directly
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
It pauses code execution until resumed
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
An exception is thrown and the `catch` block (if present) is executed
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which method would you use to inspect variables or expressions during debugging in developer tools?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`inspect()`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`trace()`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`console.error()`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`console.log()`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What kind of error is likely to occur if a function is called with an incorrect number of arguments?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Reference error
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Syntax error
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Logical error
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Type error
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which tool is commonly used to step through code line by line during debugging?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`console.log()`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`alert()`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`throw` statement
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Breakpoints in Developer Tools
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What type of error occurs when attempting to access a property of `undefined`?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Syntax error
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Logical error
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Range error
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Type error
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What does the `finally` block do in a `try...catch` statement?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Only executes if there’s an error
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Skips execution if `catch` is triggered
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Exits the code block immediately
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Always executes, regardless of errors
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following could be used to avoid runtime errors in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Skipping error handling
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Ignoring exceptions
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Using no `try...catch` statements
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Using conditionals to check data validity
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is a common cause of a syntax error?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Running out of memory
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Missing `return` statement
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Declaring an unused variable
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Missing a closing bracket
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What method could you use to track the call history of a function in the console?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`console.log()`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`console.table()`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`console.warn()`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`console.trace()`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is a "watcher" in the context of debugging?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
A tool for pausing code execution
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
A built-in function for logging errors
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
A JavaScript method for handling exceptions
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
A tool for monitoring the value of variables
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
When should you use `console.error()` instead of `console.log()`?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
To display table data
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
To log messages only during debugging
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
To log information about the browser
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
To log error messages
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What does the `Error()` constructor do in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Logs error messages to the console
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Runs code in a sandbox
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Terminates the program
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Creates a new error object that can be thrown
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What will happen if a `catch` block is not provided with a `try` block?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
The code will stop executing
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
The error will be logged but ignored
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
The program will continue with default values
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
An uncaught exception error will occur
|
||||
|
||||
|
||||
Reference in New Issue
Block a user