MediumPro challengePythonJavaScriptTypeScript

Stringify Query String

Node.jsURLStrings

Inverse of querystring.parse. Convert an object into a URL-encoded
query string. URL-encode keys and values. Skip keys whose value is null.
Sort keys alphabetically for deterministic output.

solve({ a: 1, b: 'hi there' })'a=1&b=hi%20there'.

Sample tests

Test #1Basic
Input: [{"a":1,"b":2}]
Output: "a=1&b=2"
Test #2Sorted alphabetically
Input: [{"a":1,"b":2}]
Output: "a=1&b=2"
Test #3Spaces encoded
Input: [{"q":"hi there"}]
Output: "q=hi%20there"
Test #4Empty object
Input: [{}]
Output: ""
Test #5Skip null
Input: [{"a":1,"b":null,"c":3}]
Output: "a=1&c=3"