Skip to content

Commit 7b400c2

Browse files
committed
programmatic refactor
1 parent e2e6a87 commit 7b400c2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

written/public/games/queens.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
<head>
33
<title>Queens</title>
44
<script>
5+
const maxBoardSize = 10;
56
// Generate the column rules
67
const style = document.createElement("style");
78
let cssRules = "";
89

9-
for (let i = 1; i <= 10; i++) {
10+
for (let i = 1; i <= maxBoardSize; i++) {
1011
cssRules += `
1112
#app:has(.row > *:nth-child(${i}):is(.cell.queen)) .row > *:nth-child(${i}):after,
1213
`;
@@ -26,8 +27,8 @@
2627
[1, 1],
2728
];
2829

29-
for (let i = 1; i <= 10; i++) {
30-
for (let j = 1; j <= 10; j++) {
30+
for (let i = 1; i <= maxBoardSize; i++) {
31+
for (let j = 1; j <= maxBoardSize; j++) {
3132
directions.forEach(([di, dj]) => {
3233
cssRules += `
3334
#app:has(.row:nth-child(${i}) > *:nth-child(${j}):is(.cell.queen)) .row:nth-child(${

0 commit comments

Comments
 (0)