Created
February 25, 2017 23:26
-
-
Save Underdoge/ea151517d8f764c8a3327471f4341a7e to your computer and use it in GitHub Desktop.
commonCharacterCount
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
function commonCharacterCount(s1, s2) { | |
var string1=s1.split(''); | |
var string2=s2.split(''); | |
var common=0; | |
for(var i=0;i<string1.length;i++){ | |
if(string2.indexOf(string1[i])>=0){ | |
common++; | |
string2.splice(string2.indexOf(string1[i]),1); | |
} | |
} | |
return common; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment