Skip to content

Instantly share code, notes, and snippets.

@Megajjks
Forked from oscaroceguera/Countsmiley.js
Created October 18, 2020 23:24
Show Gist options
  • Save Megajjks/8b69aaa4b63bb933ac80adbd64351566 to your computer and use it in GitHub Desktop.
Save Megajjks/8b69aaa4b63bb933ac80adbd64351566 to your computer and use it in GitHub Desktop.
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