Skip to content
Advertisement

Getting odd results from a for loop inside a filter function

I’m looping inside a filter. I want to get the values from my vals array plus the keys(name, description) for my filter.

When I iterate through my vals array, I keep getting returned the name but not the key.

Ideally I would like the return method to give me key and value.

return x[this.searchValues[i]].includes('phil')

to be return x.name.includes('phil') return x.decription.includes('phil')

JavaScript

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement