DEV Community

Discussion on: Daily Challenge #272 - Printer Errors

Collapse
 
qm3ster profile image
Mihail Malo

nodejs

const perro = wurd => {
  let i = 0
  for x of Buffer.from(wurd, "ascii") if (x > 109 || x < 97) i++
  return `${i}/${wurd.length}`
}

And a silly one:

const perro = wurd => Buffer.from(wurd, "ascii")
  .reduce((a, x) => a + (x > 109 || x < 97), 0)
  + "/" + wurd.length