Forum Discussion

manohar's avatar
manohar
Contributor
3 years ago
Solved

Filter expression on arrays

hi there, I have this json [ { "filename": [ "Coupa_Supplier_SB_Tax_Cert_PO_4501923290", "Coupa_Supplier_SB_Tax_Cert_PO_4501888888" ], "id": 16755, "docid": [ "...
  • Aleksandar_A's avatar
    3 years ago

    Hi @manohar.

    In the example you have listed, If i understand correctly don’t we also need to include the filename: Coupa_Supplier_SB_Tax_Cert_PO_4501888888? Because it exists in the docname array?

    If yes, then you can use the following expressions:

    $docname.filter((x,ind,arr) => $filename.indexOf(x) != -1)
    $docid.filter((x,ind) => $filename.indexOf($docname[ind]) != -1)
    $docext.filter((x,ind) => $filename.indexOf($docname[ind]) != -1)
    

    Let me know if this helps.

    BR,
    Aleksandar.