JSFiddle - React, Tailwind, and code Playground

by hescano

JavaScript

//return the total number of smiling faces in the array
function countSmileys(arr) {
	var regex = /^(:|;)(-|~)?(\)|D)$/;
  return arr.filter((s) => s.match(regex)).length;
}

alert(countSmileys([':D',':~)',';~D',':)']));