Gabotronix
1 month ago

Lodash filter not working with multiple conditions

Posted 1 month ago by Gabotronix

Hi everybody, I'm using lodash library to filter an array of objects but for some reason the filter it's returning the same value I pass to it, any idea what am I doing wrong?

This is the function I use to transform data:

getFlattenFields(schema)
    {
        let flatten = _.flatten(schema.fields);
        console.log('flatten',flatten);
        let filtered = _.filter(flatten, item => item.element != 'loader' || item.element != 'button' );
        console.log('filtered',filtered);
        return filtered;
    },

And my schema variable is this object:

formSchema: 
    {
        fields: 
        [
            [ 
                { id: 'email', label: '', default: '', element:'input', type: 'text' },
                { element: 'button', text:'Enviar', icon:'fas fa-reply' }, 
            ],
            [
                { element: 'loader' }, 
            ]
        ]
    }

Please sign in or create an account to participate in this conversation.