Couldn't let this kata go out of my mind, wanted to try something alternative:
const drawChessboard = (r, c) => [ ...{ * [Symbol.iterator]() { for (let i = 0; i < r; i++) yield [ ...{ * [Symbol.iterator]() { for (let j = i; j < c + i; j++) yield ['X', 'O'][j % 2] }} ] }} ]
@kosich I've fixed and simplified your approach (thanks because it help me to open mind with generators + spread operator):
const drawChessboard = (r, c) => [ ...(function* () { for (let i = 0; i < r; i++) yield [ ...(function* () { for (let j = 0; j < c; j++) yield ['O', 'X'][(i + j) % 2]; })(), ]; })(), ];
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Couldn't let this kata go out of my mind, wanted to try something alternative:
@kosich I've fixed and simplified your approach (thanks because it help me to open mind with generators + spread operator):