[Solved] Rearranging JavaScript string components [closed]
function objectify(str) { var obj = {}, arr = str.split(‘|’); for (i=0; i<arr.length;i++) { var parts = arr[i].split(‘,’); obj[parts[0]] = parts[1]; } return obj; } FIDDLE Create an empty object, split the string on | and iterate over the parts, split again on comma, and use the result as key/value pairs in the object, and … Read more