Workshop › Klondike Solitaire › Step 9 of 40
The table has seven columns, 64 pixels apart. The stock and the waste sit above columns 0 and 1, the foundations above
columns 3 to 6, and each tableau column in its own. pileX turns a pile's name into its x.
```js
const LEFT = 16
const COL = 64 // distance between columns
const colX = (i) => LEFT + i * COL
// Where each pile sits on the table.
function pileX(key) {
if (key === 'stock') return colX(0)
if (key === 'waste') return colX(1)
if (key[0] === 'f') return colX(3 + Number(key[1]))
return colX(Number(key[1]))
}
```colX(i) is the x of column i: 16, 80, 144, …key[0] is the first letter of the name, key[1] the second. Number('3') turns the text '3' into the number 3.if (...) return ... answers and stops; the last line is for the tableau columns (t0 to t6).const CH = 78 write LEFT and COL.last line write colX.deal (after its closing }), leave an empty line and write pileX with its comment.Skills: Functions
← Deal the seven columns Put the piles on the table →