Skip to content

Instantly share code, notes, and snippets.

@gravitano
Last active June 11, 2019 04:43
Show Gist options
  • Save gravitano/3bbe6e86a4cbab004cffc74af3c8221f to your computer and use it in GitHub Desktop.
Save gravitano/3bbe6e86a4cbab004cffc74af3c8221f to your computer and use it in GitHub Desktop.
function subStringBetweenTwo(a, b) {
const arr = a.split('');
const brr = b.split('');
return [...new Set(arr.filter(item => brr.includes(item)))]
}
subStringBetweenTwo('Hello', 'World')
// output: ['l', 'o']
subStringBetweenTwo('Hi', 'World')
// output: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment