Can this code be shortened using variables?

I'm not sure, PaulRB. Why did Adafruit include it if it is not needed?