Definitely, your if
series must be improved.
I did it similarly to the @Kareem's approach. I also made an array of colours with the length of the number of rows. Then in the same loop where the brick rows instantiated, I add colour feature to each brick.