Generate Random Hex Code
const randomHex = () => `#${Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, "0")}`;
console.log(randomHex());
// Result: #92b008
Generate Random Hex Code
const randomHex = () => `#${Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, "0")}`;
console.log(randomHex());
// Result: #92b008
Random Hex Color Code Generator
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Random Hex Code Generator</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans&display=swap" rel="stylesheet">
</head>
<body>
<div class="flex-row-outer">
<div class="flex-row">
<span id="hexCode">#000000</span>
<button class="colorBtn" onClick="GenerateCode()">Generate</button>
</div>
</div>
<script type="text/javascript">
let body = document.querySelector("body");
let hexCode = document.querySelector("#hexCode");
body.style.backgroundColor = hexCode.innerText;
function GenerateCode() {
let RandomColor = "";
let Char = "0123456789abcdefghijklmnopqrstuvwxyz";
for(i = 0; i < 6; i++) {
RandomColor = RandomColor + Char[Math.floor(Math.random() * 16)];
}
hexCode.innerText = "#" + RandomColor;
body.style.backgroundColor = "#" + RandomColor;
}
</script>
</body>
</html>
Generate a Random Hex Color
const hexColor = () => "#" + Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, '0')
Random HEX color
const hexColor = () => `#${Math.floor(Math.random() * 0xffffff).toString(16).padEnd(6, "0")}`;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us