Randomizing CSS based on Array value

So I figured that the last idea I had would not work, but I realized that if I attached each seperate background image from an array to a css element that, that would indeed work.

The problem is I’m not sure how I can attach them. Any help would be appreciated.