🔥 Get 650+ Tech Books and Courses for $3/m for 3 months

Generating Random Color Values using JavaScript

Sam Deering
Share

JavaScript Code snippet to generate a random RGB color. Could be useful for supplying color values to transitions to/from with a single line of code.


See Demo

var hue = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')';