Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. var string1 = "HelloWorld";
  2. var string2 = "Work";
  3.  
  4. var fn = function( string1, string2, matchChars ) {
  5. return !!string2.split("").find( function(item, index){
  6. if (index + matchChars <= string2.length )
  7. {
  8. return string1.includes( string2.substring( index, index + matchChars ) ); //check after each turn if the substring from index is included in string1 or not
  9. }
  10. return false;
  11. });
  12. }
  13.  
  14. console.log( fn("HelloWorld", "Work", 3) );
  15.  
  16. (w{3}).+(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement