Skip to content

Instantly share code, notes, and snippets.

@mattbontrager
Last active June 15, 2018 22:18
Show Gist options
  • Save mattbontrager/909ad90242a3007342cd1fef5e131bc3 to your computer and use it in GitHub Desktop.
Save mattbontrager/909ad90242a3007342cd1fef5e131bc3 to your computer and use it in GitHub Desktop.
Find the words in common between two strings.
String.prototype.same = function(str2) {
const arr1 = this.split(/\W/);
const arr2 = str2.split(/\W/);
return arr1.inCommon(arr2).join(' ');
};
// requires use of this
// https://gist.github.com/mattbontrager/2a9b71c7110ab61f9ef948208646c85f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment