Beginner
Read log lines with a regex
A server writes lines like [2024-01-15 10:30] ERROR: Disk full.
Write parseLog(line) that returns an object { date, time, level, message } (all strings) for a valid line, and null for anything else. The message can itself contain colons.
The page code then lists only the ERROR lines in #errors, as 10:30 — Disk full. That part is already written; it starts working once parseLog does.
What Check tests
- A valid line is split into date, time, level and message
- Colons inside the message are kept
- A line in the wrong shape gives
null - The page lists the two errors
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.