init
This commit is contained in:
commit
8d1008f650
1 changed files with 9 additions and 0 deletions
9
index.js
Normal file
9
index.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
function countSmileys(arr) {
|
||||||
|
const smileyPattern = /^[:;][-~]?[)D]$/;
|
||||||
|
return arr.filter((face) => smileyPattern.test(face)).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test cases
|
||||||
|
console.log(countSmileys([":)", ";(", ";}", ":-D"])); // Output: 2
|
||||||
|
console.log(countSmileys([";D", ":-(", ":-)", ";~)"])); // Output: 3
|
||||||
|
console.log(countSmileys([";]", ":[", ";*", ":$", ";-D"])); // Output: 1
|
||||||
Loading…
Add table
Add a link
Reference in a new issue