Skip to content

Instantly share code, notes, and snippets.

@chaseadamsio

chaseadamsio/k.js

Last active Aug 29, 2015
Embed
What would you like to do?
/*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