Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var string1 = "HelloWorld";
- var string2 = "Work";
- var fn = function( string1, string2, matchChars ) {
- return !!string2.split("").find( function(item, index){
- if (index + matchChars <= string2.length )
- {
- return string1.includes( string2.substring( index, index + matchChars ) ); //check after each turn if the substring from index is included in string1 or not
- }
- return false;
- });
- }
- console.log( fn("HelloWorld", "Work", 3) );
- (w{3}).+(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement