Platform
Resources
Pricing
Sign in
Get started
Alaina Holland's Workspace
Workspace
Fork
Public
By
Alaina Holland
Edited
Nov 30, 2023
1 fork
Insert cell
Insert cell
function
*
generateGrid
(
)
{
for
(
let
y
=
0
;
y
<
gridSize
;
y
++
)
{
for
(
let
x
=
0
;
x
<
gridSize
;
x
++
)
{
yield
{
x
,
y
}
;
}
}
}
Insert cell
grid$
=
generateGrid
(
)
;
Insert cell
grid$
.
(
(
data
)
=>
{
console
.
log
(
data
)
;
}
)
;
Insert cell
// Set the size of the grid
gridSize
=
8
;
Insert cell
// Loop through rows (y-axis)
for
(
let
y
=
0
;
y
<
gridSize
;
y
++
)
{
let
row
=
''
;
// Loop through columns (x-axis)
for
(
let
x
=
0
;
x
<
gridSize
;
x
++
)
{
// Create cells or elements here
row
+=
`[${
x
},${
y
}] `
;
}
console
.
log
(
row
)
;
// Output the row in the console
}
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
generateGrid
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
grid$
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
gridSize
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML