Skip to content

Commit 51e561f

Browse files
committed
basic color flipper finished
1 parent 469042e commit 51e561f

19 files changed

Lines changed: 219 additions & 1036 deletions

File tree

‎01-color-flipper/final/app.js‎

Lines changed: 0 additions & 15 deletions
This file was deleted.

‎01-color-flipper/final/hex.html‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎01-color-flipper/final/hex.js‎

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎01-color-flipper/final/index.html‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎01-color-flipper/final/styles.css‎

Lines changed: 0 additions & 234 deletions
This file was deleted.

‎01-color-flipper/setup/app.js‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
const colors = ["green", "red", "rgba(133,122,200)", "#f15025"];
1+
const colors = ["green", "red", "rgba(133,122,200)",
2+
"#f15025"];
3+
4+
const colorSpan = document.querySelector('.color');
5+
const btn = document.getElementById('btn');
6+
7+
let randomNumber = getRandomNumber();
8+
9+
btn.addEventListener('click', function() {
10+
11+
const color = document.querySelector('.background').style.backgroundColor = colors[getRandomNumber()];
12+
colorSpan.innerHTML = color;
13+
});
14+
15+
16+
function getRandomNumber() {
17+
return Math.floor(Math.random() * colors.length)
18+
}
19+

‎01-color-flipper/setup/hex.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
const hex = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F"];
1+
const hex = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
2+
"A", "B", "C", "D", "E", "F"];

0 commit comments

Comments
 (0)