Created
September 4, 2021 05:55
-
-
Save madeleine68/420edf13e964ef54b32828540d603d97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const urlDecode = function(text) { | |
// Put your solution here | |
result = {}; | |
let splitText = text.replace(/%20/g, ' ') | |
.split('&') | |
.map(x => x.split("=")); | |
splitText.forEach( function(elm) { | |
// statements | |
result[elm[0]] = elm[1] | |
}); | |
return result; | |
}; | |
console.log(urlDecode("duck=rubber")); | |
console.log(urlDecode("bootcamp=Lighthouse%20Labs")); | |
console.log(urlDecode("city=Vancouver&weather=lots%20of%20rain")); | |
console.log(urlDecode("city=Vancouver&weather=lots%20of%20rain").weather); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment