Challenge - 5 Problems
Deno Cron Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediateWhat does this Deno cron task output?
Consider this Deno script using the cron module. What will it print to the console after 3 seconds?
Deno
import { Cron } from "https://deno.land/x/croner@6.0.0/mod.ts"; const task = new Cron("*/1 * * * * *", () => { console.log("Tick"); }); setTimeout(() => { task.stop(); console.log("Stopped"); }, 3000);
Attempts:
2 left
💡 Hint
The cron runs every second until stopped after 3 seconds.
✗ Incorrect
The cron runs every second (*/1 * * * * *). After 3 seconds, it stops. So it prints "Tick" 3 times, then "Stopped".
📝 Syntax
intermediateWhich cron expression runs a task every 5 minutes?
You want to schedule a task in Deno to run every 5 minutes. Which cron expression is correct?
Attempts:
2 left
💡 Hint
Standard cron has 5 fields: minute, hour, day, month, weekday.
✗ Incorrect
The expression "*/5 * * * *" means every 5 minutes. Deno's Cron supports 5 or 6 fields; 5 fields is standard for minutes precision.
🔧 Debug
advancedWhy does this Deno cron task never run?
Look at this code snippet. Why does the scheduled task never print "Hello"?
Deno
import { Cron } from "https://deno.land/x/croner@6.0.0/mod.ts"; const task = new Cron("60 * * * * *", () => { console.log("Hello"); });
Attempts:
2 left
💡 Hint
Seconds in cron expressions range from 0 to 59.
✗ Incorrect
The seconds field cannot be 60. This invalid value prevents the task from running.
❓ state_output
advancedWhat is the value of count after this Deno cron script runs?
This script increments count every 2 seconds and stops after 5 seconds. What is the final count value?
Deno
import { Cron } from "https://deno.land/x/croner@6.0.0/mod.ts"; let count = 0; const task = new Cron("*/2 * * * * *", () => { count++; }); setTimeout(() => { task.stop(); console.log(count); }, 5000);
Attempts:
2 left
💡 Hint
Count increments every 2 seconds until stopped at 5 seconds.
✗ Incorrect
The cron triggers at 0s, 2s, 4s (3 times). At 5s it stops and prints count = 3.
🧠 Conceptual
expertWhich statement about Deno's Cron module is true?
Choose the correct statement about how Deno's Cron module schedules tasks.
Attempts:
2 left
💡 Hint
Consider how JavaScript event loops handle scheduled callbacks.
✗ Incorrect
Deno's Cron callbacks run on the main event loop synchronously. Long-running tasks can block other code.
