Skip to content

Instantly share code, notes, and snippets.

@jafar-jabr
Last active December 18, 2021 09:33
Show Gist options
  • Save jafar-jabr/9352cbf8d257391c0c095d8364f0cb09 to your computer and use it in GitHub Desktop.
Save jafar-jabr/9352cbf8d257391c0c095d8364f0cb09 to your computer and use it in GitHub Desktop.
Javascript common substring
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