I want to filter the class but got error .filter is not a function
23:22 05 Aug 2026

I got a div in Javascript, which has two classes one for category(specific for each) and one for CSS styling. I got that div correct div in .closest method but I want to fetch its category class which is any one of these:
Nature or Trivia or Sports or Food.
HTML:

Nature

Test your wildlife knowledge about our amazing green planet.

Trivia

Guess random quiz facts and challenge your brain with tests.

Food

Guess global dishes and test your taste buds with good food.

Sports

Guess athletic leagues and test your scores in game matches.

Javascript:

 const selectedCategoryDiv = selectedCategory.closest('.sports, .trivia, .nature, .food');
  const category = selectedCategoryDiv.classList.filter(cls => cls !== '.category-cards');
  console.log(category);
javascript debugging dom functional-programming