0
0
Node.jsframework~20 mins

Debugging with VS Code in Node.js - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
VS Code Debugging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🔧 Debug
intermediate
2: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');
AThe code has a syntax error before line 5.
BThe file is not saved before starting the debugger.
CThe breakpoint is set on a comment line.
DThe debugger is not attached to the running process.
Attempts:
2 left
💡 Hint
Check if the debugger is connected to the right process.
component_behavior
intermediate
1: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');
AIn the Terminal panel of VS Code.
BIn the Debug Console panel of VS Code.
CIn a popup alert window.
DIn the Problems panel of VS Code.
Attempts:
2 left
💡 Hint
Think about where debug output usually shows in VS Code.
📝 Syntax
advanced
2: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?
A{ "type": "node", "request": "launch", "name": "Launch Program", "program": "${workspaceFolder}/app.js" }
B{ "type": "node", "request": "attach", "name": "Attach to Program", "program": "app.js" }
C{ "type": "node", "request": "launch", "name": "Start Debug", "file": "app.js" }
D{ "type": "node", "request": "start", "name": "Run Debug", "program": "app.js" }
Attempts:
2 left
💡 Hint
Check the correct keys for launch configuration.
state_output
advanced
2: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);
A1
B0
C6
D3
Attempts:
2 left
💡 Hint
The breakpoint on line 6 is after the loop; calculate the final value of count.
🧠 Conceptual
expert
3: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?
AIt allows the debugger to map the compiled JavaScript back to the original TypeScript source code.
BIt speeds up the debugging process by skipping source files.
CIt enables debugging of external libraries automatically.
DIt disables breakpoints in JavaScript files.
Attempts:
2 left
💡 Hint
Think about how TypeScript compiles to JavaScript and how debugging works.