Here’s a fun little program that will ask you your name and then insult you. Charming, eh?

The nice thing about it is that it clearly shows how to write a program in JavaScript that takes some input from the user, does something with it (in this case creates an insulting string) and outputs it as text. It also shows how arrays (i.e. lists) work in JavaScript, and how to randomly select an item from a list.

See the Pen Insult Generator in Javascript by John (@jgbell100) on CodePen.


Big thanks to CoderDojo Stirling for letting us use their code.