Siemka, co byście poprawili w kodzie, jak ocenianie?
Krótki kod ale pewnie i tu znajdzie się coś do zaczepienia usunięcia żeby nie weszło w nawyk
<html>
<head>
<title>Website</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<button class="changeBackground">Change</button>
<canvas id="canvas" width="300" height="300"></canvas>
<script src="script.js"></script>
</body>
</html>
body{
padding: 0;
justify-content: center;
}
.changeBackground{
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size:16px
}
const background = document.querySelector('body');
const changeBackground = document.querySelector('.changeBackground');
changeBackground.addEventListener('click', function(){
console.log('x2');
console.log(changeRandom());
document.body.style.backgroundColor = changeRandom();
})
function changeRandom(){
let abc = ['A','F','0','6','7','8','1','2','3','4']
let abcSecond = ['A','C','D','E','F','0','6','7','1','2','3','4']
let hash = '#';
let sumHas = abc[Math.floor(Math.random() * (abc.length))];
let sumHash2 = abcSecond[Math.floor(Math.random() * (abcSecond.length))];
let sumHash3 = abcSecond[Math.floor(Math.random() * (abcSecond.length))];
let sumHash4 = abcSecond[Math.floor(Math.random() * (abcSecond.length))];
let sumHash5 = abcSecond[Math.floor(Math.random() * (abcSecond.length))];
let sumHash6 = abcSecond[Math.floor(Math.random() * (abcSecond.length))];
let x = sumHas + sumHash2 + sumHash4 + sumHash3 + sumHash5 + sumHash6;
let sumHex = hash.concat(x)
let a = sumHex;
return a;
}
console.log(changeRandom());