문제 링크 : Count Asterisks
/**
* @param {string} s
* @return {number}
*/
var countAsterisks = function(s) {
let pair=0, count=0;
for(let c of s){
if(c == '|') pair++;
if(pair % 2 == 0 && c == '*') count++;
}
return count;
};
/**
* @param {string} s
* @return {number}
*/
var countAsterisks = function(s) {
return s.split('|').filter((_, i) => i % 2 === 0).join('').split('*').length - 1;
};