score:0

Accepted answer

i solved this by doing the following

filteredpayload: state. mypayload.filter(item => {
                switch (item.type) {
                case 'building':
                    return (
                        item.name.tolowercase().match(value)
                            || item.country.tolowercase().match(value)
                            || item.state.tolowercase().match(value)
                    );
                case 'student':
                case 'teacher':
                    return (
                        item.name.tolowercase().match(value)
                            || item.age.tolowercase().match(value)
                            || item.height.tolowercase().match(value)
                    );
                }

                return item;
            }),

thank you all for helping out ^_^

score:2

you could just search in the values of the object, so you do not really need to care about the key names.

filteredpayload: state.mypayload.filter(item => (
  object.values(item).some(objvalue => (
    objvalue.tolowercase().match(value)
  ))
))

Related Query

More Query from same tag