Skip to content

Instantly share code, notes, and snippets.

@oscaroceguera
Created October 18, 2020 23:22
Show Gist options
  • Save oscaroceguera/17863c9b67d654546830036ec17bb54f to your computer and use it in GitHub Desktop.
Save oscaroceguera/17863c9b67d654546830036ec17bb54f 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