menghasilkan nomor warna RGB acak.
'#'+(0x1000000+(Math.random())*0xffffff).toString(16).substr(1,6)
Bewildered Bat
'#'+(0x1000000+(Math.random())*0xffffff).toString(16).substr(1,6)
function getRandomRgb() {
var num = Math.round(0xffffff * Math.random());
var r = num >> 16;
var g = num >> 8 & 255;
var b = num & 255;
return 'rgb(' + r + ', ' + g + ', ' + b + ')';
}
for (var i = 0; i < 10; i++) {
console.log(getRandomRgb());
}
Run code snippet