Frontend Coding: Traffic Light
Build a simple traffic light component using HTML + CSS + JavaScript.
Requirements
-
Render a vertical traffic light with
three circles
: red, yellow, green.
-
Exactly
one
light is “on” at a time (brighter color); the others are “off” (dimmed).
-
The light should
cycle automatically
in this order:
-
Red for
R
milliseconds
-
Green for
G
milliseconds
-
Yellow for
Y
milliseconds
-
Repeat
-
Provide a simple way to start the cycle when the page loads (e.g.,
window.onload
).
Optional extensions (if time)
-
Add
Start / Pause / Reset
controls.
-
Allow changing
R/G/Y
durations without reloading.
-
Ensure timers don’t stack (no multiple overlapping intervals/timeouts).
Deliverable
-
A single HTML page (or separate HTML/CSS/JS files) that demonstrates the cycling traffic light in a browser.