myVariable.and is not a function?

Hello,

I’m trying to combine some variables to be used as a filter based on the value of a dropdown menu and a search bar. However, whenever I try to run the code and use the search bar I am presented with:

Here is my code for reference:

I’m confused as to why I am getting this kind of error because searchBarFilter should be a variable, not a function and I was able to implement similar code on a similar page. The error also occurs if I swap dropDownFilter and searchBarFilter, which leads me to believe there is some kind of error in my syntax rather than the variables themselves.


This code works just fine.

Can anyone see what might be wrong with my code that would be throwing that error? Thanks in advance.

[@nathanael] You have several issues here.

  1. Every time you use setFilter the dataset will get filtered. It doesn’t accumulate filters or even return then it applies them.
  2. There is no value returned by setFilter. You need to get familiar with the documentation:

SetFilter returns Promise:void this essentially means nothing. Since void doesn’t have a .and() function you get a type error because the variable searchBarFilter is undefined.

Try using console.log(typeof searchBarFilter); To see what JavaScript thinks you have.

Thanks!