Skip to content

Commit ce3b9a8

Browse files
committed
Removed stuff that was unnecessary, leaving only random hex color generator
1 parent 133c642 commit ce3b9a8

4 files changed

Lines changed: 35 additions & 36 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎1-color-flipper/setup/hex.html‎

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

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
11
const hex = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F"];
2+
3+
const btn = document.getElementById('btn');
4+
const color = document.querySelector('.color');
5+
6+
btn.addEventListener('click', function() {
7+
let hexColor = '#';
8+
for (let i = 0; i < 6; i++) {
9+
const randomNumber = getRandomNumber();
10+
hexColor += hex[randomNumber];
11+
}
12+
// Grab a random number between 0-16
13+
document.body.style.backgroundColor = hexColor;
14+
color.textContent = hexColor;
15+
});
16+
17+
function getRandomNumber() {
18+
return Math.floor(Math.random() * hex.length);
19+
}

‎1-color-flipper/setup/index.html‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,23 @@
99
<link rel="stylesheet" href="styles.css" />
1010
</head>
1111
<body>
12-
<h1>color flipper</h1>
12+
<nav>
13+
<div class="nav-center">
14+
<h4>Color Flipper</h4>
15+
<ul class="nav-links">
16+
<li>
17+
<a href="index.html">Hex</a>
18+
</li>
19+
</ul>
20+
</div>
21+
</nav>
22+
<main>
23+
<div class="container">
24+
<h2>Background Color: <span class="color">#F1F5F8</span></h2>
25+
<button class="btn btn-hero" id="btn">Click Me</button>
26+
</div>
27+
</main>
1328
<!-- javascript -->
14-
<script src="app.js"></script>
29+
<script src="hex.js"></script>
1530
</body>
1631
</html>

0 commit comments

Comments
 (0)