5

Random RGB Generator

Function JavaScript 1 revisions 293 8 days ago 8 days ago
const randomRgbGenerator = () => {
  const round = Math.round
  const random = Math.random
  const number = 255

  const r = round(random() * number)
  const g = round(random() * number)
  const b = round(random() * number)

  return { r, g, b }
}

console.log(randomRgbGenerator())
// { r: 116, g: 34, b: 150 }