-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (30 loc) · 1.02 KB
/
index.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
var header = document.querySelector("#header");
var input = document.querySelector("#input");
var div = document.getElementById("container");
function getRandomColor() {
var letters = "0123456789ABCDEF";
var color = "#";
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
var clicked = function () {
header.style.color = input.value;
header.innerHTML = input.value;
var c = input.value.split("").reverse().join("");
var rearrangedString = c.slice(-1) + c.slice(0, -1);
header.style.backgroundColor = rearrangedString;
div.style.backgroundColor = input.value;
};
var AnotherClick = function () {
var hex = getRandomColor();
header.style.color = hex;
header.innerHTML = hex;
var reversedHex = hex.split("").reverse().join("");
var rearrangedString = reversedHex.slice(-1) + reversedHex.slice(0, -1);
header.style.backgroundColor = rearrangedString;
input.value = hex;
div.style.backgroundColor = hex;
};
AnotherClick();