function setQueryStringParameter(name, value) {
const params = new URLSearchParams(window.location.search);
params.set(name, value);
window.history.replaceState({}, "", decodeURIComponent(`${window.location.pathname}?${params}`));
}
// Easy Way - how to add parameters to url javascript
const MyURL = new URLSearchParams(window.location.search);
MyURL.set('Name', 'HazaaZOOZ');
window.location.search = MyURL;
let params = new URLSearchParams(window.location.search);
console.log(params.get(name));
you can use backticks ``
// url params
const elemA = "Los Angelis";
const elemB = "London";
window.location.href = `http://www.gorissen.info/Pierre/maps/googleMapLocation.php?lat=${elemA}&lon=${elemB}&setLatLon=Set`;