JSFiddle - React, Tailwind, and code Playground

by cmoreira

JavaScript

var v = ["84636,84637,84638,84639,84640,84641,84642,84643,84644",
					"84621,84622,84623,84630,84631,84632,84639,84640,84641",
          "84620,84623,84626,84629,84632,84635,84638,84641,84644"];

final_query=[];

v.forEach(function(elm){

				if (typeof final_query["post__in"] === 'undefined') {
					final_query["post__in"] = elm.split(",");
				} else {
        
      		var pin = elm.split(",");
          
          final_query["post__in"] = arrayIntersect(final_query["post__in"],pin);
           	
        }
        
        console.log(final_query);

});

function arrayIntersect(a, b)
{
    return jQuery.grep(a, function(i)
    {
        return jQuery.inArray(i, b) > -1;
    });
};