Skip to content

Instantly share code, notes, and snippets.

@oscaroceguera
Created October 18, 2020 23:25
Show Gist options
  • Save oscaroceguera/8cb2e37348e9ceb68d3c8347911c1bc2 to your computer and use it in GitHub Desktop.
Save oscaroceguera/8cb2e37348e9ceb68d3c8347911c1bc2 to your computer and use it in GitHub Desktop.
function countSmileys(arr) {
let count = 0;
let validFace = [
":)",
";)",
":-)",
";-)",
":~)",
";~)",
":D",
";D",
":-D",
";-D",
":~D",
";~D"
];
arr.map(item => {
validFace.map(vitem => {
if (item.includes(vitem)) count++;
});
});
return arr.length == 0 ? 0 : count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment