Last active
December 18, 2021 09:33
-
-
Save jafar-jabr/9352cbf8d257391c0c095d8364f0cb09 to your computer and use it in GitHub Desktop.
Javascript common substring
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
function commonSubstring(a, b) { | |
a.forEach((row, index) => { | |
const otherString = b[index] ?? ''; | |
if(row.split('').some((letter) => otherString.indexOf(letter) !== -1)) { | |
console.log('YES'); | |
}else{ | |
console.log('NO'); | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment