Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q14 of 15
Node.js - HTTP Module
Identify the error in this code snippet:
const querystring = require('querystring');
const url = 'name=Alice&city=Wonderland';
const parsed = querystring.parse(url);
console.log(parsed.name, parsed.city);
Aquerystring module is not imported correctly
Bparse() cannot parse strings without '?' prefix
CNo error, code works correctly
Dparsed object properties should be accessed with brackets
Step-by-Step Solution
Solution:
  1. Step 1: Check module import

    The module is imported correctly using require.
  2. Step 2: Check parse usage and property access

    parse() accepts query strings without '?' and properties accessed correctly with dot notation.
  3. Final Answer:

    No error, code works correctly -> Option C
  4. Quick Check:

    querystring.parse works on plain query strings [OK]
Quick Trick: parse() works without '?' prefix in query string [OK]
Common Mistakes:
  • Thinking '?' is required in parse input
  • Assuming bracket notation is mandatory
  • Believing import syntax is wrong

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes