This code is more efficient yet. The box is drawn black first and then the color is changed by selecting the relevant button. I didn't need the timeout function. I can do all the drawing in one function. No need for if statements. Simplied version of http://bl.ocks.org/brennanpincardiff/8e56ef6f51564955aeea
As I learn more code, I realise that I can write more efficient code. The code here is more efficient than the previous version (http://bl.ocks.org/brennanpincardiff/6dc3a53908c2e8611498)
I have made the code more efficient again: http://bl.ocks.org/brennanpincardiff/d07d52f10900c14844b5
Teaching myself how to use radio boxes, I created this simple example that allows me to change the color of a square by selecting a different circle. This is inspired by the code from here: http://bl.ocks.org/mbostock/3943967.
I have learned more about coding and I have created a more efficient way to do this here: http://bl.ocks.org/brennanpincardiff/d07d52f10900c14844b5