{"ScriptPreparationCode":"var querystring = \u0027foo=bar\u0026baz=qux\u0026quxx=corge\u0026grault=garply\u0026waldo=fred\u0026plugh=xyzzy\u0027\r\n\r\nvar queryobj = {\r\n foo: \u0027bar\u0027,\r\n baz: \u0027qux\u0027,\r\n quux: \u0027corge\u0027,\r\n grault: \u0027garply\u0027,\r\n waldo: \u0027fred\u0027,\r\n plugh: \u0027xyzzy\u0027\r\n}\r\n\r\nfunction encode(data) {\r\n let result = \u0027?\u0027\r\n\r\n for (const key in data) {\r\n if (data[key] != null) {\r\n result \u002B= key \u002B \u0027=\u0027 \u002B data[key] \u002B \u0027\u0026\u0027\r\n }\r\n }\r\n\r\n return result.slice(0, -1)\r\n}\r\n\r\nfunction encodeNative(data) {\r\n return new URLSearchParams(data).toString()\r\n}\r\n\r\nfunction buildQueryString(params) {\r\n const query = Object.entries(params)\r\n .filter(([_, value]) =\u003E value !== undefined \u0026\u0026 value !== null)\r\n .map(([key, value]) =\u003E \u0060${key}=${encodeURIComponent(String(value))}\u0060)\r\n .join(\u0027\u0026\u0027);\r\n\r\n return query ? \u0060?${query}\u0060 : \u0027\u0027;\r\n}","TestCases":[{"Name":"URLSearchParams","Code":"encodeNative(queryobj)","IsDeferred":false},{"Name":"Custom","Code":"buildQueryString(queryobj)","IsDeferred":false},{"Name":"Custom 2","Code":"encode(queryobj)","IsDeferred":false}]}