-
-
Save Megajjks/8b69aaa4b63bb933ac80adbd64351566 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 countSmileys(arr) { | |
let smiles = 0; | |
let eyes = [";", ":"]; | |
let noses = ["-", "~"]; | |
let mouth = [")", "D"]; | |
for (let i = 0; i < arr.length; i++){ | |
if (arr[i].length == 3){ | |
if (((eyes.indexOf(arr[i][0]) != -1)) && (noses.indexOf(arr[i][1]) != -1) && (mouth.indexOf(arr[i][2]) != -1)){ | |
smiles++; | |
} | |
} else if (arr[i].length ==2){ | |
if ((eyes.indexOf(arr[i][0]) != -1) && (mouth.indexOf(arr[i][1]) != -1)){ | |
smiles++; | |
} | |
} | |
} | |
return smiles; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment