I would like to create function which filter items in an array for a specific value passed in.
Currently I am using template literal to pass the value for RegEx to its constructor, but with no success.
What I am doing wrong in my code?
The result should be an array filtered (in this example with 2 items).
let data = ['Gone With the Wind', 'Star Wars: Episode IV', 'Jaws', 'Matrix', 'Matrix backstage', 'Star Wars: Episode I', 'WindWind' ];
let filter = (data, value) =>{
//return data.filter(s => s.match(/value/i))
return data.filter(s => s.match(`/${value}/i`))
};
console.log(filter(data, 'Wind'));