-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (30 loc) · 765 Bytes
/
Copy pathapp.js
File metadata and controls
34 lines (30 loc) · 765 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
34
const colorBtn = document.querySelector('#btn-1');
const boxes = document.querySelectorAll('.box');
let running = false;
function getRandomColor(){
let letters = "0123456789ABCDEF"
let color = '#'
for(let i = 0; i < 6; i++){
color += letters[Math.floor(Math.random() * 16)]
}
return color
}
function startThisShit(){
if(running){
boxes.forEach(color => {
color.style.background = getRandomColor();
})
setTimeout(startThisShit, 50);
}
}
colorBtn.addEventListener('click', function(){
colorBtn.innerText = 'Desligar Paredão';
if(running){
running = false;
colorBtn.innerText = 'Ligar Paredão'
}
else{
running = true;
startThisShit()
}
})