for loop - Looping through 2 lists in javascript -
I have 2 lists, I need to recycle them and duplicate removed from the main list. Ex: The output should be such that china dc and so on ... But now I get the output, all the duplicates of DC are twice. How to loop in script. Pls help I will use underscore.js () which is the _.uniq function (an array of Removes duplicate) as well as removes many other convenient functions for your problem. What you probably want: ListA = {[25151, "China DC", "14 March 2014"], [8171, "Singapore IMT", "14 March 2014"]} ListB = {Object {id = 3, dcName = " Argentina {ID = 631}, object {id = 101, dcName = "ASEAN", country = "ASEAN"}, object {id = 2, dcName = "Brazil DC" country ID = 631} 6, DCN name = "Central Europe", country code = 668}, commodity {ID = 5, DCNM = "China DC", country code = 672}} (var i = 0; i & lt; (list) [Ja] [1] == List B. [i] .dcName) {} else {htmlStr + = dcList [i] .dcName; }}}
singapore imt
argentina dc
aiaan
brasil dc
// get all DC values allDC = []; (Var key in ListB) {allDC.push (ListB [dcName]); } // delete the duplicates allDC = _.uniq (allDC); // Remove from list first (list key in list A) {ListA [key] = _.filter (ListA [key], function (object) {return _.indexOf (object, allDC) === -1; }); }
Comments
Post a Comment