const rX = 'xX';
const rO = 'oO';
let rCountX = 0;
let rCountO = 0;
for (let i = 0; i < str.length; i++) {
if (rX.includes(str[i])) {
rCountX++;
} else if (rO.includes(str[i])) {
rCountO++;
}
}
rCountX === rCountO ? true : false;
const rCount = Array.prototype.reduce.call(str, (acc, letter) => {
if (rX.includes(letter)) {
acc.X++;
} else if (rO.includes(letter)) {
acc.O++;
}
return acc;
}, { X: 0, O: 0 });
const rCount = Array.prototype.reduce.call(str.toLowerCase(), (acc, letter) => {
switch(letter) {
case 'x':
acc.X++;
break;
case 'o':
acc.O++;
break;
}
return acc;
}, { X: 0, O: 0 });
const { x: countX = 0, o: countO = 0 } = Array
.from(str.toLowerCase())
.reduce((acc, n) => (acc[n] = (acc[n] ?? 0) + 1, acc), {});
const [ countX, countO ] = [ /x/i, /o/i ].map(n => ~-str.split(n).length);