I have a wired requirement for one of the my JS code.
In JS I have an array like below:-
const modNames = ['CW652', 'MNOP200', '100ABCD', 'XYZ200'];
Now I need to write a function which will return true if an input string is contained by any array element or any array element is contained by the input string. e.g. CW652, CW652-100, ABCD, MNOP and XYZ are valid input and function should return true.
I tried below code and its not working
var str = 'CW652-100';
const subArr = modNames.some(str => str.includes(substr) || substr.includes(str));