re: Daily Challenge #81 - Even or Odd VIEW POST

FULL DISCUSSION
 

My solution in js


const evenOrOdd = (str) => {
  const evenCount = (`${str}`.match(/[02468]/g) || '').length,
    oddCount = (`${str}`.match(/[13579]/g) || '').length;
  return (evenCount === oddCount) ? 'Even and Odd are the same' : (evenCount > oddCount ) ? 'Even is greater than Odd' : 'Odd is greater than Even';
};

code of conduct - report abuse