I'm messing around with the the example code on the MDN page detailing Array.prototype.filter(), and I'm finding something interesting happening.
I modified the example code to be the following:
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.includes('e', 'i'));
console.log(result);
// expected output: const result = words.filter(word => word.includes('e', 'i'));
console.log(result); // expected output: Array ["elite", "exuberant", "destruction", "present"]
And it works, however when I modify it so those two characters are located in a variable (either declared with const OR var)...
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
var test = ['e', 'i'];
const result = words.filter(word => word.includes(test));
console.log(result);
// expected output: Array ["elite", "exuberant", "destruction", "present"]
// ACTUAL OUTPUT: Array []
Lastly, if I change test to test[0,1] I get the first result - as expected.
Other similar looking questions didn't seem to help me, and I'm not quite sure what's happening here, or how I can make this work.
ihere, so the version without a variable is also incorrect.