code:
function makeQuery(queryObject) { const query = Object.entries(queryObject) .reduce((result, entry) => { result.push(entry.join('=')) return result }, []).join('&') return `?${query}` }
sample:
const queryObject = {name: "nameValue", code: "codeValue"}; const objectEntries = Object.entries(queryObject) => [["name","nameValue"],["code","codeValue"]] const arrayReduce = objectEntries.reduce((result, entry)=> { result.push(entry.join("=")); return result }, []) => ["code=codeValue","name=nameValue"] `?arrayReduce.join('&')`