Skip to content

Instantly share code, notes, and snippets.

@KatrinaHoffert
Created January 13, 2015 06:08
Show Gist options
  • Save KatrinaHoffert/a57d1a193fd87ef6a211 to your computer and use it in GitHub Desktop.
Save KatrinaHoffert/a57d1a193fd87ef6a211 to your computer and use it in GitHub Desktop.
/*jshint multistr:true */
text = "Blah blah blah blah blah blah Eric \
blah blah blah Eric blah blah Eric blah blah \
blah blah blah blah blah Eric";
var myName = "Eric";
var hits = [];
for(var i = 0; i < text.length; i++){
if (text[i] == "E"){
for(var j = i; j < (myName.length + i); j++){
hits.push(text[j]);
}
}
}
if (hits.length === 0){
console.log("Your name wasn't found!");
} else {
console.log(hits);
}
@KatrinaHoffert
Copy link
Author

Not my code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment