Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 13, 2016 21:08
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/e525fc37d5d9a64c9c85bfc02a2362e0 to your computer and use it in GitHub Desktop.
Save codecademydev/e525fc37d5d9a64c9c85bfc02a2362e0 to your computer and use it in GitHub Desktop.
Codecademy export
/*jshint multistr:true */
text="Hello, my name is Adam and i'm from China. Adam is my name."
var myName="adam"
var hits=[]
for (var i = 0; text.length > i; i++) {
if ( text[i] === "a") {
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