Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created September 1, 2016 06:13
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/ee698ed6f6fd1d3fda385e7161fb964c to your computer and use it in GitHub Desktop.
Save codecademydev/ee698ed6f6fd1d3fda385e7161fb964c to your computer and use it in GitHub Desktop.
Codecademy export
/*jshint multistr:true */
var text = "This is a string and it is Richard's, \ it loves Richard and only Richard"
var myName = "Richard"
hits = []
for ( var i = 0; i <= text.length; i++ ){
if (text[i] === "R")
{
for ( var j = i; j < i + myName.length; j++ ){}
{hits.push(text[i])}}}
console.log(hits)
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