-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript.js
More file actions
33 lines (30 loc) · 915 Bytes
/
javascript.js
File metadata and controls
33 lines (30 loc) · 915 Bytes
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
//Made by Mark Snodgrass, DK, Josh Turner, Alex Minnick
function changeColor(squareID) {
var square = document.getElementById(squareID);
var randomColor = getRandomColor();
square.style.backgroundColor = randomColor;
}
let intervalId = null;
function randomColor() {
const letters = "0123456789ABCDEF";
let color = "#";
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
function flashColors() {
const flashes = document.querySelectorAll(".flash");
flashes.forEach(function (flash) {
const randomColorValue = randomColor();
flash.style.backgroundColor = randomColorValue;
});
}
function toggleFlashing() {
if (intervalId) {
clearInterval(intervalId);
intervalId = null;
} else {
intervalId = setInterval(flashColors, 100);
}
}