We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c0ca2ae commit 5fcfb03Copy full SHA for 5fcfb03
project1-colors/src/Button.js
@@ -5,7 +5,10 @@ export default function Button({ $target, onClick }) {
5
6
$button.addEventListener("click", (e) => {
7
const generateRandomColorCode = () => {
8
- return Math.floor(Math.random() * 16777215).toString(16);
+ const randomHex = Math.floor(Math.random() * 16777215).toString(16);
9
+ return randomHex.length < 6
10
+ ? `${"0".repeat(6 - randomHex.length)}${randomHex}`
11
+ : randomHex;
12
};
13
onClick(generateRandomColorCode());
14
});
0 commit comments