function handlePriceFilter() { const priceFilterCheckbox = $('.price-filter'); priceFilterCheckbox.change(function(e) { if ($(this).is(':checked')) { const min = $(this).data('price-min'); const max = $(this).data('price-max'); addPriceFilterToUrl(min, max); return; } removePriceFilterFromUrl(); }); function addPriceFilterToUrl(min, max) { const parsedUrl = getUrlVars(); parsedUrl['price_min'] = min; parsedUrl['price_max'] = max; makeUrl(parsedUrl); } function removePriceFilterFromUrl() { const parsedUrl = getUrlVars(); delete parsedUrl['price_min']; delete parsedUrl['price_max']; makeUrl(parsedUrl); } }