Q:

recreate an array where name matches with the substring and channeltype is equal to Ota

public data = [
        {
            'name': 'Item 1', 'channelType': 'ota'
        },
        {
            'name': 'Item 2', 'channelType': 'ota'
        },
        {
            'name': 'Item 3', 'channelType': 'ota'
        },
        {
            'name': 'Item 4', 'channelType': 'ota'
        },
        {
            'name': 'Item 5', 'channelType': 'direct'
        },
        {
            'name': 'Item 6', 'channelType': 'direct'
        },
        {
            'name': 'Item 7', 'channelType': 'direct'
        },
]

I would like to use filter or reduce or may be both to return all arrays where name contains a substring and channel type = ota 
Let me write clearly what i want to do,
I have one text input and two check box . It all
condition 1: All the input will work together to filter the data.
condition 1: It will check if the input is a substring of name. 
condition 2: It will check if the checkbox is of channel type ota, if it is ota, it will list all the ota channel type
condition 3: It will check if the checkbox is of channel type direct, if it is direct, It will list all direct channel type
condition 4: If both of the checkbox is selected then all the data is returned and also checks for the input name for substring

A:

Use filter() and supply the predicate that you wish to filter on.
const filtered = data.filter(d => d.name.includes('substring') && d.channelType === 'ota');

