Created
July 15, 2015 16:46
-
-
Save TimurM/a474ac9db93bd623ba5a to your computer and use it in GitHub Desktop.
This file contains 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
queryMap = { | |
name: 'Timur', | |
last_name: 'Meyster', | |
email: '[email protected]' | |
} | |
var turnMapToArray = function(queryMap) { | |
var queryResult = [] | |
for (var key in queryMap) { | |
queryResult.push([key, queryMap[key]]) | |
} | |
return queryResult; | |
} | |
var joinArrayStrings = function(arrayStr) { | |
return arrayStr.reduce(function(joinedArray, arrayItem) { | |
return joinedArray.concat(arrayItem.join("=")); | |
}, []) | |
} | |
var convertToQueryStr = function(arrayKeyValueStr) { | |
return arrayKeyValueStr.join("&"); | |
} | |
console.log(convertToQueryStr(joinArrayStrings(turnMapToArray(queryMap)))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment