We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Tough Tricky javascript question with array and random funtion

I got a tricky javascript question relating to random function and arrays, which I have ask around but no one seems to understand or able to solve.
For testing purpose, a fixed number value is hardcoded to the variable.
I would like to achieve the following result:
- 12 black stay fixed on "b" spot
- Followed by 53 red to be random place within only the 'r' spots on refresh or button click
('r' spot is every 3 row, first 15 box)
- Unfilled 'r' spots + rest of unfilled box fill with lightblue = 19, lime = 34, yellow = 17, pink = 42, green = 102 random position on refresh or button click
There should be no unfilled box
https://jsfiddle.net/e4rcorzd/
I trying my luck here, see who can solve it.

Loader.
Live Chat Icon For mobile
Up arrow icon