Q: Filtering array based on checkbox conditional values So, I'm a bit stuck. I'm filtering an array based on the values of another array. When the user clicks a check box a year value gets pushed to an array (checkedBoxes), then the yearMarker array is populated from meeting the condition IF the marker.year (from mapMarkers array) entry is equal to any value in the CheckedBoxes array. This then gets passed to the getMarkers function which populates the map I'm working on. This all works perfectly. However when I click uncheck the box it doesn't work. If I log the checkedBoxes array I can see that the year is being removed as it should. The code to populate/replace yearMarkers is the same as the checked state, as with the function to create map markers. Yet it doesn't work. Any help to straighten out my thinking on this would be appreciated.  
subFilter.forEach(item => {
    const elm = item;
    item.addEventListener('click', function () {
        if (elm.checked) {
            markersLayer.clearLayers();
            checkedBoxes.push(elm.value);
            yearMarkers = mapMarkers.filter(marker => checkedBoxes.includes(marker.year));
            getMarkers(yearMarkers, markersLayer);
        } else{
            checkedBoxes = checkedBoxes.filter(entry => entry !== elm.value);
            yearMarkers = mapMarkers.filter(marker => checkedBoxes.includes(marker.year));
            getMarkers(yearMarkers, markersLayer);
            console.log('unchecked');
            console.log(checkedBoxes);
        }
    })

