function addParamIntoUrl(param, value) { const currentUrl = window.location.href const newparam = currentUrl.indexOf('?') > -1 ? `&${param}=${value}` : `?${param}=${value}` const newurl = currentUrl + newparam window.history.pushState({ path: newurl }, '', newurl) }