Workshop › Chess › Step 5 of 48
A single letter hides the color in its case. We turn each letter into two: the color ('w' or 'b') and the kind in
capitals, like 'wN' or 'bQ'. An empty square becomes ''.
```js
board = START.map((line) => [...line].map((ch) => (ch === '.' ? '' : (ch === ch.toUpperCase() ? 'w' : 'b') + ch.toUpperCase())))
```map runs on each letter ch of a row.''. Otherwise: if ch equals its capital form it is white ('w'), else black ('b'); then +
adds the kind in capitals.'n' → 'b' + 'N' → 'bN'.Replace the line inside reset with the new one.
Skills: Arrays and objects, Types and values
← The starting position as text Draw the pieces →