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
It occurred to me that I could improve my code by having only one function and passing the color into the function rather than having three functions as detailed in
http://bl.ocks.org/brennanpincardiff/6dc3a53908c2e8611498