DEV Community

Discussion on: JavaScript Katas: Letterbox Paint Squad

Collapse
 
kosich profile image
Kostia Palchyk • Edited

My turned-out-to-be-similar solution:

const paintLetterboxes = (start, end) =>
  Array(1 + end - start)
  .fill()
  .map((_, i) => start + i)
  .flatMap(n => n.toString().split(''))
  .reduce((a, c) => (a[c] += 1, a), Array(10).fill(0))

First time I actually used flatMap :)

-

Btw, IMHO, kata description in a code-box is not the best UX-wise because of additional scrolling...

maybe quotes would fit better?


or separators?


Collapse
 
miku86 profile image
miku86 • Edited

Hey Kostia,

yes, you are right,
will search for a better solution, thanks!