index.tsx275 chars9 lines
Explanation:
animals
containing animals of different categories including 'cats' and 'dogs'.excludedCategories
containing the categories we don't want to include in our result.filter
method on the animals
array with a callback function that does the filtering.includes
method to check if the current animal is included in the excludedCategories
array.!
, so we get the animals that are NOT in those categories.filter
method returns a new array containing the filtered animals that do not belong in 'cats' or 'dogs'.result
array to the console to confirm.gistlibby LogSnag