Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

finallyayo

🏠
Working from home
View GitHub Profile
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Hex colour generator</title>
<link rel="stylesheet" href="/assets/css/style.css" />
</head>
<body>
<div class="container">
<h1>Hex Color Code: <span class="hexValue">#ffffff</span></h1>
<button class="btn">Click me</button>
View style.css
html {
box-sizing: border-box;
}
*, *::before, *::after {
margin: 0;
padding: 0;
box-sizing: inherit;
}
View script.js
const hexValues = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F'];
const button = document.querySelector('.btn');
const body = document.querySelector('body');
const value = document.querySelector('.hexValue');
function changeHex() {
let hex = '#';
for (let i = 0; i < 6; i++) {
const index = Math.floor(Math.random() * hexValues.length);