7 kyu
Do you know how to make Query String?
569 of 1,278isqua
Description:
Query string is a way to serialize object, which is used in HTTP requests. You may see it in URL:
codewars.com/kata/search/?q=querystring
The part q=querystring
represents that parameter q
has value querystring
. Also sometimes querystring used in HTTP POST body:
POST /api/users
Content-Type: application/x-www-form-urlencoded
username=warrior&kyu=1&age=28
The string username=warrior&kyu=1&age=28
represents an entity (user in this example) with username equals warrior, kyu equals 1 and age equals 28. The entity may be represented as object:
{
"username": "warrior",
"kyu": 1,
"age": 28
}
Sometimes there are more than one value for property:
{
"name": "shirt",
"colors": [ "white", "black" ]
}
Then it represents as repeated param:
name=shirt&colors=white&colors=black
So, your task is to write a function that convert an object to query string:
toQueryString({ foo: 1, bar: [ 2, 3 ] }) // => "foo=1&bar=2&bar=3"
Next you may enjoy kata Objectify a URL Query String.
Note: require
has been disabled.
Algorithms
Data Structures
Strings
Similar Kata:
Stats:
Created | Jun 27, 2017 |
Published | Jun 27, 2017 |
Warriors Trained | 2671 |
Total Skips | 33 |
Total Code Submissions | 8140 |
Total Times Completed | 1278 |
JavaScript Completions | 569 |
TypeScript Completions | 78 |
Python Completions | 610 |
Ruby Completions | 80 |
Crystal Completions | 3 |
Total Stars | 36 |
% of votes with a positive feedback rating | 86% of 271 |
Total "Very Satisfied" Votes | 212 |
Total "Somewhat Satisfied" Votes | 43 |
Total "Not Satisfied" Votes | 16 |
Total Rank Assessments | 10 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |