Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript:compare two arrays and returns match

function select(arr, obj) {
  const result = {};
  for (let name of arr) {
    if (name in obj) {
      result[name] = obj[name];
    }
  }
  return result;
}
Source by www.30secondsofcode.org #
 
PREVIOUS NEXT
Tagged: #arrays #returns #match
ADD COMMENT
Topic
Name
4+8 =