Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

filter json array based on multiple arguments including lists

 const array = [{ sector_code: ..., listed_in: ... }]; // your array
  const listed_inilter = ['KSE100', 'KMIALLSHR'];
  const sector_code = ['0833', '0824'];

  function array_subset() {
     return array.filter(element => {
       const is_listed = listed_inilter.some(item => element.listed_in.includes(item));

       const is_sector = sector_code.includes(element.sector_code);

       return (is_listed || is_sector)
  });
}

console.log(array_subset()); // output the filtered list
    
 
PREVIOUS NEXT
Tagged: #filter #json #array #based #multiple #arguments #including #lists
ADD COMMENT
Topic
Name
5+5 =