Skip to content

Instantly share code, notes, and snippets.

@LeeXun
Created November 7, 2017 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeeXun/c2811c36001c2ad0d21e372c2002e44c to your computer and use it in GitHub Desktop.
Save LeeXun/c2811c36001c2ad0d21e372c2002e44c to your computer and use it in GitHub Desktop.
module.exports = function isSubstring(a, b) {
let i = 0
while(i < a.length - b.length){
let j = 1
if(a[i] == b[0]){
while(true){
if(a[i+j] == b[j]){
if(j == b.length - 1){
return i + j
}
j += 1
continue;
} else { break; }
}
}
i += 1
}
return -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment