Platform
Resources
Pricing
Sign in
Get started
Andrew Wooldridge
📜JavaScript developer. 🐲RPG fan. 📚Storyteller and 🕹game developer. 👨Father and Husband.
Workspace
Fork
Published
2 collections
By
Andrew Wooldridge
Edited
Oct 22, 2021
3 stars
Insert cell
Insert cell
moonArray
=
[
"🌕"
,
"🌖"
,
"🌗"
,
"🌘"
,
"🌑"
,
"🌒"
,
"🌓"
,
"🌔"
]
Insert cell
function
*
animateMoon
(
)
{
let
i
=
0
;
while
(
true
)
{
i
++
;
if
(
i
>=
moonArray
.
length
)
{
i
=
0
}
yield
moonArray
[
i
]
}
}
Insert cell
animateMoon
(
)
Insert cell
function
*
animateMoonSlower
(
msec
)
{
let
i
=
0
;
while
(
true
)
{
yield
new
Promise
(
resolve
=>
{
i
++
;
if
(
i
>=
moonArray
.
length
)
{
i
=
0
}
setTimeout
(
(
)
=>
resolve
(
moonArray
[
i
]
)
,
msec
)
;
}
)
;
}
}
Insert cell
animateMoonSlower
(
1000
)
Insert cell
ossliate
=
Math
.
round
(
Math
.
sin
(
now
*
.001
)
*
moonArray
.
length
/
2
+
moonArray
.
length
/
2
)
Insert cell
function
*
ossilateMoon
(
)
{
while
(
true
)
{
yield
moonArray
[
ossliate
<
moonArray
.
length
?
ossliate
:
0
]
}
}
Insert cell
ossilateMoon
(
)
Insert cell
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
Listed in...
Tips and Utilities
Andrew Wooldridge
Random Bits
Andrew Wooldridge
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
moonArray
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
animateMoon
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
animateMoonSlower
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
ossliate
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
ossilateMoon
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML