Ed

Building URLs with query parameters is something you'll do constantly when working with APIs. Let's build a utility function that handles all the edge cases.

Your Task:

  • Create a function buildQueryString(params) that takes an object
  • Return a properly formatted query string starting with ?
  • Use Object.entries() to iterate over the object
  • Use encodeURIComponent() for proper URL encoding
  • Filter out null or undefined values
  • Example: { name: "Alice", age: 25 }"?name=Alice&age=25"
TypeScript Solution
Loading...

Submit your code to see test results