-2
var job = ['javascript','nodejs','angularjs','css','html','graphql'];
var candidate= ['javascript','node', 'css', 'html', 'postgres', 'sql', 'express', 'python', 'c#'];

Hi everyone, I have these two arrays, I would like to find how many matches candidate has with job description, so in this case javascript, node, css, html = 4 matches. I am just trying to find the best way to check and make sure to count same languages and frameworks. thank you guys

hackrack
  • 85
  • 7

1 Answers1

0

Use filter which will return a new array and use includes to get elements which is common to both array

var job = ['javascript', 'nodejs', 'angularjs', 'css', 'html', 'graphql'];
var candidate = ['javascript', 'node', 'css', 'html', 'postgres', 'sql', 'express', 'python', 'c#'];

var m = job.filter(function(item) {
  return candidate.includes(item);
})
console.log(m)

Also note nodejs and node will be considered different while finding the common element

brk
  • 48,835
  • 10
  • 56
  • 78