I have a big function in Javascript that I need to repeat the same logic, except for the line bellow, that is different:
config.some(x => x.site === text)
The other function will do the same thing, but instead of filtering by SITE, it will filter by NAME:
config.some(x => x.name === text)
I want to pass SITE or NAME as a parameter to the method. How can I do this?
I was hoping for something like this:
myMethod(lambda) {
config.some(lambda === text)
}
And call like:
this.myMethod(x => x.site);
myMethod(lambda) { return config.some(x => lambda(x) === text); }