Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

How do i write a script which generates a random rgb color number.

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
Comment

PREVIOUS NEXT
Code Example
Javascript :: download pdf in javascript 
Javascript :: Round Decimals to a Certain Number of Decimal Places 
Javascript :: use localstorage hook 
Javascript :: import and export type in js 
Javascript :: javascript how to pass more than one selector in querySelectorall 
Javascript :: mongodb text search exact match 
Javascript :: js add to array 
Javascript :: mongoose nested object without id 
Javascript :: yup validation based on another field value 
Javascript :: using python with javascript 
Javascript :: libuv nodejs 
Javascript :: json to string 
Javascript :: string theory 
Javascript :: javascript addeventlistener button 
Javascript :: split and convert a string into object 
Javascript :: node-schedule job on specific datetime 
Javascript :: node cron schedule specific time 
Javascript :: Simple interest in javascript 
Javascript :: update in mongoose node js 
Javascript :: jquey datatables 
Javascript :: react router reload page not found 
Javascript :: Return the highest number in Arrays in JavaScript 
Javascript :: video conferencing app with html and js 
Javascript :: how to create request body javascript 
Javascript :: create callback function javascript 
Javascript :: delete duplicate array javascript 
Javascript :: check if array contain the all element javascript 
Javascript :: how to split an array into two javascript 
Javascript :: onclick multiple functions react 
Javascript :: sort numbers in array in js 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =