Skip to content

Instantly share code, notes, and snippets.

@curiouslychase
Last active August 29, 2015 13:56
Show Gist options
  • Save curiouslychase/8873152 to your computer and use it in GitHub Desktop.
Save curiouslychase/8873152 to your computer and use it in GitHub Desktop.
/*jshint multistr:true */
var text = "Lorem ipsum Kat sit amet, KrisKris adipiscing elit. Vestibulum Kite consectetur lorem, KKris aliquam turpis Kilts nec. Nam vel mattis."
var myName = "Kris";
var hits = [];
var count = 0;
console.log("**********************");
for (var i=0; i<= text.length; i++)
{
if(text[i]=="K")
{
var tempArray = text.slice(i, i + myName.length);
console.log(tempArray);
if (tempArray == myName)
{
count++;
}
}
}
console.log(myName,"found",count,"times");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment