-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
45 lines (23 loc) · 840 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const color =['blue','green','yellow','orange','pink','brown'];
function colorChange(){
let colorsRandomChanges = backgroundRandom();
document.body.style.background= color[colorsRandomChanges]
document.querySelector(".inputrgb").textContent= color[colorsRandomChanges];
}
// to add common output on background color and text color notification.
function backgroundRandom(){
return Math.floor(Math.random()*color.length);
};
// rgb color coding
const rgb = [0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F'];
function changeToRbg(){
let hexcode ="#";
for(let i=0; i<6; i++){
hexcode+= rgb[getRandom()];
}
document.querySelector(".inputrgb").textContent= hexcode;
document.body.style.background= hexcode;
}
function getRandom(){
return Math.floor(Math.random()*rgb.length);
}