Background color random change

Hi there,

My client wants the background color of the website to change randomly when a visitor clicks on a page in the menu. She wants 8 different, specified colors, to be randomly applied.

I found this link: https://teamtreehouse.com/community/random-background-color

My questions are: is this code OK to use and should I add it to theme functions.php file?

Any other advices and/or experiences to share with me?

Thanks in advance, best regards,

Ronald