Platform
Resources
Pricing
Sign in
Get started
Andrew Wooldridge
📜JavaScript developer. 🐲RPG fan. 📚Storyteller and 🕹game developer. 👨Father and Husband.
Workspace
Fork
Published
By
Andrew Wooldridge
Edited
Mar 3, 2022
1 star
Insert cell
Insert cell
generateRandomHexColor
=
(
)
=>
`#${
Math
.
floor
(
Math
.
random
(
)
*
0xffffff
)
.
toString
(
16
)
}`
;
Insert cell
color
=
{
yield
generateRandomHexColor
(
)
}
Insert cell
out
=
html
`${
myTable
(
)
}`
Insert cell
myTable
=
(
)
=>
{
let
output
=
`<table >${
renderRow
(
12
)
}</table>`
return
output
}
Insert cell
renderRow
=
(
rows
)
=>
{
let
out
=
``
for
(
let
i
=
0
;
i
<
rows
;
i
++
)
{
out
=
`${
out
} <tr>${
renderCell
(
12
)
}</tr>`
}
return
out
}
Insert cell
renderCell
=
(
cells
)
=>
{
let
out
=
``
;
for
(
let
i
=
0
;
i
<
cells
;
i
++
)
{
let
color
=
generateRandomHexColor
(
)
out
=
`${
out
} <td style="background-color:${
color
}">${
color
}</td>`
;
}
return
out
;
}
Insert cell
<
style
>
td
{
padding
:
6
px
;
}
td
{
border
:
1
px
solid
black
;
}
</
style
>
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
generateRandomHexColor
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
color
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
out
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
myTable
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
renderRow
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
renderCell
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML