How to check if a sub-array contains all elements of another array javascript

I have an array of projects called rawProjects which looks like this:

rawProjects = [
    {
         id: 1,
         name: "proj1",
         technology: [
             0: {id: 21, project_id: 1,name: "java"},
             1: {id: 22, project_id: 1,name: "c++"}
          ]
    },
    {
         id: 2,
         name: "proj2",
         technology: [
             0: {id: 23, project_id: 2,name: "sql"},
             1: {id: 24, project_id: 2,name: "python"},
             2: {id: 25, project_id: 2,name: "react"}

         ]
    }
]

I also have an array of technology called tempTags which contains the technologies that the user enters to search from. So far I have been able to do the OR case where in I return the projects which contain either of the technologies mentioned by the user using:

const filteredProjects = rawProjects.filter(x => x.technology.some(g => tempArr.includes(g.name)))

So for example if tempTags = [sql, c++] both projects will be returned.

How do I implement the AND case such that only projects that contain both of these technologies are returned. Eg if tempTags = [java, c++] , only the first project will be returned. If tempTags = [sql, c++], nothing will be returned?

94 thoughts on “How to check if a sub-array contains all elements of another array javascript”

  1. First of all I want to say wonderful blog! I had a
    quick question that I’d like to ask if you do not mind.
    I was curious to find out how you center yourself and clear your head before
    writing. I’ve had difficulty clearing my thoughts in getting
    my thoughts out there. I do take pleasure in writing however it just seems like
    the first 10 to 15 minutes are usually lost simply just trying to figure out
    how to begin. Any recommendations or hints?

    Many thanks! http://antiibioticsland.com/Augmentin.htm

    Reply
  2. pharmacie lafayette limoges pharmacie beaulieu louviers , du therapies breves lyon 1 pharmacie auchan trinite , Zyrik venta online, DГіnde comprar Zyrik 300. Zyrik en farmacia Argentina Comprar Zyrik genГ©rico [url=https://kit.co/erlipi/zyrik-venta-online-comprar-zyrik-sin-receta#]Zyrik Allopurinol 300[/url] therapie de couple besanГ§on Comprar Reactine sin receta, DГіnde comprar Reactine analgesics. Reactine en farmacia Colombia Comprar Reactine genГ©rico [url=https://kit.co/pestrogca/comprar-reactine-sin-receta-donde-comprar-reactine-analgesics#]Comprar Reactine sin receta[/url] , pharmacie en ligne versailles pharmacie beauvais lesigny , pharmacie bailly saint lazare horaires. pharmacie apell annecy Comprar Glimda genГ©rico, DГіnde comprar Glimda diabetes. Comprar Glimda sin receta Comprar Glimda genГ©rico [url=https://kit.co/renchalkhost/glimda-en-farmacia-argentina-comprar-glimda-generico#]Glimda Glimepiride diabetes[/url] , pharmacie fouassier bourges horaires pharmacie de garde marseille 20 juillet, pharmacie de garde ouverte aujourd’hui hyeres pharmacie annecy fermeture 20h . pharmacie en ligne livraison uk, pharmacie aix en provence avenue jules ferry grande pharmacie avignon nord traitement cystite .

    Reply