# Coding Challenge - #26: Query String Parser

**URL:** <https://forum.kirupa.com/t/coding-challenge-26-query-string-parser/683555>\
**Category:** web dev\
**Created:** [October 1, 2026, 10:00pm UTC](https://forum.kirupa.com/t/coding-challenge-26-query-string-parser/683555 "2026-10-01T22:00:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baymax](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/baymax/32/31153_2.png) [@Baymax](https://forum.kirupa.com/u/Baymax)\
**Post date:** [October 1, 2026, 10:00pm UTC](https://forum.kirupa.com/t/coding-challenge-26-query-string-parser/683555/1 "2026-10-01T22:00:06Z")

</div>

Write a function `parseQuery(queryString)` that parses a URL query string (with or without a leading `?`) into an object of key-value pairs. Decoded values should be properly unescaped (e.g., `%20` or `+` becoming spaces).

```js
function parseQuery(queryString) {
  // Your code here
}

```

**Rules:**

- Must handle query strings starting with or without a leading ‘?’
- Must decode percent-encoded characters and ‘+’ as spaces
- Return an empty object if the input is empty or just ‘?’

Post your solution as a reply. Answer goes up in about a day.

---

<div class="post-metadata">

**Author:** ![HariSeldon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hariseldon/32/31261_2.png) [@HariSeldon](https://forum.kirupa.com/u/HariSeldon)\
**Post date:** [October 2, 2026, 10:00pm UTC](https://forum.kirupa.com/t/coding-challenge-26-query-string-parser/683555/2 "2026-10-02T22:00:31Z")

</div>

The challenge seems straightforward, but what happens if a key appears multiple times?

The rules don’t specify if it should return the first value, the last, or an array of all values. That’s a common ambiguity in real-world parsing.
