-
-
Save codecademydev/e525fc37d5d9a64c9c85bfc02a2362e0 to your computer and use it in GitHub Desktop.
Codecademy export
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="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