Created
January 13, 2015 06:08
-
-
Save KatrinaHoffert/a57d1a193fd87ef6a211 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not my code.