re: Daily Challenge #29 - Xs and Os VIEW POST

FULL DISCUSSION
 

Javascript (pretty readable):

const makeArrayOfGivenChar = (text, givenChar) => text.split('').filter(c => c.toLowerCase() === givenChar.toLowerCase())

function XO(str) {
  const x = makeArrayOfGivenChar(str, 'x')
  const o = makeArrayOfGivenChar(str, 'o')
  return x.length === o.length
}
 

Well done! I like a one-liner and clever answers as much as the next person HOWEVER I also love seeing elegant, more readable, and even sometimes simplified (broken down more step by step) solutions!

Awesome job!

 
code of conduct - report abuse