var filterBy = window.location.search.substring(10);
if(filterBy !==""){
if(filterBy ==='all'){
$('#filterItems').find('[data-type]').show();
}else{
$('#filterBy li').removeClass('active');
$('#filterBy').find('li[data-filter= "'+ filterBy + '"]').addClass('active');
$('#filterItems').find('[data-type]').hide().end().find('[data-type*="' + filterBy + '"]').show();
}
}
I want to make it optimized. filterBy==="" and filterBy === all. I feel its checking two times for condition. I want to have only condition check