doc: timer example

This commit is contained in:
Artemy 2022-08-29 22:13:33 +03:00
parent 3f20238d9c
commit fcf90eff0a

28
examples/timer.onla Normal file
View file

@ -0,0 +1,28 @@
[
{
let: {
seconds: { toNumber: { input: "Enter the seconds to count down: " } },
},
},
{
loop: [
{
if: {
condition: { comp: [{ var: "seconds" }, "<=", 0] },
body: ["break"],
},
},
[{ var: "seconds" }, " seconds left"],
{
assign: {
seconds: { calc: [{ var: "seconds" }, "-", 1] },
},
},
{ sleep: 1000 },
"clear",
],
},
["Time's up"],
]