Prompt
Write a JavaScript function `parseQuery(qs)` that parses a URL query string into an object. - Leading `?` is optional and ignored. - Percent-encoding is decoded (`%20` → space) and `+` means space. - A key that appears more than once collects its values into an array, in order. - A key with no `=` (e.g. `flag`) maps to an empty string `""`. - Empty input returns `{}`. Example: `parseQuery("?a=1&b=hi%20there&a=2&flag")` → `{ a: ["1", "2"], b: "hi there", flag: "" }`. Put it in a single JavaScript code block and `module.exports = parseQuery` (or `module.exports = { parseQuery }`). It will be required from `./solution.js`.
fill the variables
This prompt has 2 variables. Pro fills them into a ready-to-paste prompt for you — no manual find-and-replace.
{a: ["1", "2"], b: "hi there", flag: ""}{parseQuery}
Unlock with Pro →when to use it
Community prompt sourced from the open-source GitHub repo Green-PT/honey-for-devs (MIT). A "Prompt" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.
tags
codingcommunitydeveloper
source
Green-PT/honey-for-devs · MIT
more in Coding
Coding✓ tested
Senior code review (strict mode)
senior staff engineer running a merciless but fair review
Coding✓ tested
Debug by hypothesis, not by guessing
debugging partner who forms theories before touching code
Coding✓ tested
Generate tests from described behavior
test engineer who writes tests that would actually catch regressions