From what the comments say and what I see, I think your hide
variable is meant to contain an arrow function.
It should be re-written to this (as shown in the comments).
hide = e => e.style.display = "none";
Also, the func
parameter as an argument isn't bound to the passed in element, it is bound to a variable as one of the function's arguments (in this case, it contains the function of hide
.
In addition, you also have to call functions with ()
.
Otherwise, it means pretty much nothing in your context;
So, in your while loop, change this:
elem[i].func;
to this:
func(elem[i]);
This executes your function as a callback and passes in the element as an argument.
One more thing: since I don't see hide declared anywhere else (or redeclared for that matter), if the latter is true then I recommend using a const
variable declaration keyword.
So, your hide function declaration statement should be changed to this:
const hide = e => e.style.display = "none";
This tells the interpreter that you are declaring a variable.
While technically (in non-strict mode), omitting the variable declaration keyword is oftentimes accepted, it's bad practice.
For more info, see: What is the purpose of the var keyword and when should I use it (or omit it)?
You also seem to be having trouble with arrow functions.
I recommend reading this to eliminate any confusion with how arrow functions are used/formed.