Press the button, get a quote and a new background colour. Press the other button, tweet it.
It is running above. Press it a few times.
That is the entire program, and it is here because it was the first thing I built that another person clicked on without me standing next to them.
What is actually in it
- A local array of quote and attribution pairs — Wells, Napoleon, Russell, Patton, Rand, Michelangelo, Yoda
- A random hex colour generated per press, applied to the background and the button border so the whole page recolours as one
- A Twitter share button built at runtime through the Twitter widgets API, recreated on each new quote so the share text always matches what is on screen
Looking back at it
The colour generator is '#' + Math.floor(Math.random() * 16777215).toString(16), which is a
neat trick and also subtly wrong — values below 0x100000 produce a short string and a
malformed colour, so roughly one press in sixteen would have produced an invalid hex code that
the browser silently ignored. I did not notice at the time. It is a good early lesson in the
difference between “works when I tried it” and “correct.”
Hosted on my first personal website, which no longer exists. The source is public now, and it is about forty lines — the whole thing fits on one screen.