Convert “a=1&b=2” into {a:”1”, b:”2”}. function str2Obj(str){ if (typeof str !== 'string') return str; if (str.indexOf('&') < 0 && str.indexOf('=') < 0) return {}; return str.split('&').reduce((acc,pair)=>{ if(pair.includes('=')){ const [k,v] = pair.split('='); acc[k]=v; } return acc; },{});}