Skip to content

Instantly share code, notes, and snippets.

@madeleine68
Created September 4, 2021 05:55
Show Gist options
  • Save madeleine68/420edf13e964ef54b32828540d603d97 to your computer and use it in GitHub Desktop.
Save madeleine68/420edf13e964ef54b32828540d603d97 to your computer and use it in GitHub Desktop.
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