Skip to content

Instantly share code, notes, and snippets.

@jasp402
Last active March 5, 2019 19:49
Show Gist options
  • Save jasp402/94e920fca3ca1585cd88da64de2ac299 to your computer and use it in GitHub Desktop.
Save jasp402/94e920fca3ca1585cd88da64de2ac299 to your computer and use it in GitHub Desktop.
JavaScript: Search array in Array
let text = 'c';
let findText = [text];
let inArray = ["a",'c','d','g']
let result = [];
findText.find(text => inArray.forEach(arrValue=>text == arrValue && result.push(text)));
console.log(JSON.stringify(result));
// expected output: 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment