js: Randomly get an RGB color value

The implementation code is as follows

function randomColor() {
    
    
  let r = Math.floor(Math.random() * 255);
  let g = Math.floor(Math.random() * 255);
  let b = Math.floor(Math.random() * 255);

  return `rgb(${
      
      r},${
      
      g},${
      
      b})`;
}

console.log(randomColor());
// rgb(178,134,78)

Guess you like

Origin blog.csdn.net/mouday/article/details/132424261