The array of strings to filter
The substring to search for within each string
A new array containing only strings that include the filter substring
const fruits = ['apple', 'banana', 'apricot', 'grape'];
filterStringArray(fruits, 'ap'); // ['apple', 'apricot']
filterStringArray(fruits, 'ban'); // ['banana']
filterStringArray(fruits, 'xyz'); // []
// Empty filter matches all strings
filterStringArray(fruits, ''); // ['apple', 'banana', 'apricot', 'grape']
// Case sensitive
filterStringArray(['Hello', 'hello'], 'H'); // ['Hello']
Filters an array of strings to include only those that contain the specified substring. Uses the native String.includes() method for case-sensitive substring matching.