Last active
March 5, 2019 19:49
-
-
Save jasp402/94e920fca3ca1585cd88da64de2ac299 to your computer and use it in GitHub Desktop.
JavaScript: Search array in Array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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