Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 9, 2017 23:21
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 codecademydev/1927b5301f92efdc762c61b423331589 to your computer and use it in GitHub Desktop.
Save codecademydev/1927b5301f92efdc762c61b423331589 to your computer and use it in GitHub Desktop.
Codecademy export
/*jshint multistr:true */
var text = "Hey, how are you \
doing? My name is Kyle. Kyle enjoys coding, but more importently, Kyle likes talking in third person.";
var myName = "Kyle";
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text[i] === "K") {
for (var j = i; j < i + myName.length; j++) {
hits.push(text[j]);
}
}
}
if (hits === 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