-
-
Save curiouslychase/8873152 to your computer and use it in GitHub Desktop.
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 */ | |
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