Challenge - 5 Problems
VS Code Debugging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🔧 Debug
intermediate2:00remaining
Identify the cause of the breakpoint not hitting
You set a breakpoint in VS Code on line 5 of your Node.js file, but when you run the debugger, it never pauses there. What is the most likely reason?
Node.js
console.log('Start'); function greet() { console.log('Hello'); } greet(); console.log('End');
Attempts:
2 left
💡 Hint
Check if the debugger is connected to the right process.
✗ Incorrect
If the debugger is not attached, breakpoints won't be hit. Setting breakpoints on comments or unsaved files won't cause this issue. Syntax errors usually prevent the program from running.
❓ component_behavior
intermediate1:30remaining
What happens when you use 'console.log' inside a VS Code debug session?
During a Node.js debug session in VS Code, you add console.log statements inside your code. Where will the output appear?
Node.js
console.log('Debugging output');Attempts:
2 left
💡 Hint
Think about where debug output usually shows in VS Code.
✗ Incorrect
Console.log output during debugging appears in the Debug Console, not the Terminal or Problems panel.
📝 Syntax
advanced2:30remaining
Which launch.json configuration correctly starts a Node.js debug session?
You want to debug a Node.js file named app.js using VS Code. Which launch.json snippet will correctly launch the debugger?
Attempts:
2 left
💡 Hint
Check the correct keys for launch configuration.
✗ Incorrect
The 'launch' request with 'program' key pointing to the file is correct. 'attach' is for attaching to running processes. 'file' and 'start' are invalid keys.
❓ state_output
advanced2:00remaining
What is the value of 'count' when the debugger pauses at the breakpoint?
Consider this Node.js code with a breakpoint on line 6. What is the value of 'count' when paused there?
Node.js
let count = 0; for(let i = 0; i < 3; i++) { count += i; debugger; } console.log(count);
Attempts:
2 left
💡 Hint
The breakpoint on line 6 is after the loop; calculate the final value of count.
✗ Incorrect
The loop iterates three times (i=0: count=0; i=1: count=1; i=2: count=3). The breakpoint is on line 6 after the loop completes, so count=3. The 'debugger;' statements cause pauses inside the loop, but the breakpoint on line 6 is hit after continuing past them.
🧠 Conceptual
expert3:00remaining
Why use 'sourceMaps' in VS Code debugging for Node.js?
You are debugging a Node.js app written in TypeScript using VS Code. Why is setting "sourceMaps": true in launch.json important?
Attempts:
2 left
💡 Hint
Think about how TypeScript compiles to JavaScript and how debugging works.
✗ Incorrect
Source maps connect the compiled JavaScript to the original TypeScript, letting you debug the original code instead of the compiled output.