1function generateRandomColor() {
2 var letters = '0123456789ABCDEF';
3 var color = '#';
4 for (var i = 0; i < 6; i++) {
5 color += letters[Math.floor(Math.random() * 16)];
6 }
7 return color;
8}
9
10var randomColor=generateRandomColor();//"#F10531"
1var randomColor = '#'+Math.floor(Math.random()*16777215).toString(16);
2//generates a random color -> #56eec7
1//1.
2var color = '#'+Math.floor(Math.random()*256).toString(10);
3//2.
4var color = '#'+Math.floor(Math.random()*0xffffff).toString(16);
5//3.
6function rgb(){// rgb color random
7 var r = Math.floor(Math.random()*256);
8 var g = Math.floor(Math.random()*256);
9 var b = Math.floor(Math.random()*256);
10 var rgb = 'rgb('+r+','+g+','+b+')';
11 return rgb;
12 }
13//4.
14function color16(){// hexadecimal color random
15 var r = Math.floor(Math.random()*256);
16 var g = Math.floor(Math.random()*256);
17 var b = Math.floor(Math.random()*256);
18 var color = '#'+r.toString(16)+g.toString(16)+b.toString(16);
19 return color;
20}