4 kyu
Objectify a URL Query String
2,895 of 2,907OverZealous
Loading description...
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
JS Node 18. should be enabled
decodeURIComponent
function is not mentioned anywhereI'm curious but why is the node version so low to not allow
URLSearchParams
iterating over that, splitting, and then reconstructing recersivly is still a good kata. Why teach 20 year old code practises?Easy one)
You can do reverse function for fun:) Nice kata
sorry - another kata :) https://www.codewars.com/kata/52859abdf8fc1b12e0000141/solutions/javascript
Hi.
I have wrote a code and it was successfully tested aside from codewars code execution environment. But when I'm trying to post it here, codewars nagging for my regular expression.
How can I know what exactly is wrong. The issue occurs only in local environment.
Having some problems with handling repeated property names. :(
Took some time to fully understand but successfully completed. HINTS: create a reference variable to create nested objects. You can mutate referenced object to apply change in the result object. You can also use the concept of deep cloning objects to get a hint.
This comment has been hidden.
kata hint != kata suggestion
ez points ;)
I think I am pretty close, passing 5, but still failing two when going to submit. Basic test button passes. Not sure what "should be able to handle repeated properties" means, any ideas?
An interesting task, but the main thing is that there is a real use when parsing a URL string. Not just an abstract agglomeration, but from a real development. Thank.
This comment has been hidden.
Because
a
property should equal given value:a%26b%3Dc%3F
(ora&b=c?
decoded). You shouldn't be decoding the string until you're assigning its value, that's why encoding is there to begin with, so there's no conflicts with charaters=
or&
when used as values. (I know you solved it already, this is for anyone else who gets confused)I am getting this error:
Expected property "a" to be "a&b=c?" but was "a%26b%3Dc%3F". Expected output
{"a":"a&b=c?"}
Need help.
Read the description more carefully. It says:
You did not decode the URI components.
what the imput string here? a=a%26b%3Dc%3F ?
investigate the function unescape()
Nice kata... real life application
Pretty nice "real world" kata.
It would be nice to specify what do with empty keys or values. That is, should the string
return
{"foo": "", "bar": "baz"}
or just{"bar": "baz"}
? I implemented the former behavior, but I have seen other solutions that do the latter. I think it would be good to have a test case that demands the one or the other.This comment has been hidden.
Your code fails when dealing with an empty query string. Please read the output when submitting the code.
I don't know why it's failing on the example tests for me, but that used to work, and I haven't changed anything. I think it's a Codewars bug.
This comment has been hidden.
That only works if the order of the keys maintains constant. This is not only not guaranteed within JavaScript, but has already been proven to cause issues earlier.
It might be a fluke that the solution you see passed when it was written. It's possible that an updated Node engine is more strict. I specifically expect an empty object with no keys if the input string is empty.
Good kata, it plays nicely and builds upon the solutions to the "Name Your Space" kata: http://www.codewars.com/kata/514b6c44a337752e67000077
Thank you, I'm glad you liked it!
I liked that this wasn't as time consuming as some other things, e.g. implementing sorting algorithms or primality tests. Also didn't require a ton of research into 'magic' abilities of built-in objects.
I thought it was reasonably easy, to be honest. Using map (no IE7 support necessary, yay), solving this kata was fun. You threw me with URI Encoding #2 though, at first. Took only a minute or so to fix, though.
That's great! I'm glad you enjoyed it.
I liked this kata, almost tempted to use eval xD but NOOO! I solved in another way ;)
I lost a night of sleep over this kata, but it was worth it, nice one :)
Sorry you lost a night of sleep, but glad you enjoyed it. Don't forget to peruse the other solutions to compare to yours!
Fun kata.