You are on page 1of 1

<!

DOCTYPE html>
<html>
<head>
<title>Rzut monetą</title>
<style>
body {
background-color: #f2f2f2;
}
h1 {
text-align: center;
font-family: Arial, sans-serif;
font-size: 36px;
margin-top: 50px;
}
img {
display: block;
margin: auto;
width: 200px;
height: 200px;
}
button {
display: block;
margin: auto;
margin-top: 50px;
padding: 10px 20px;
background-color: #4CAF50;
color: #fff;
font-size: 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Rzuć monetą!</h1>
<img id="coin" src="https://www.random.org/images/mexican-peso/Mexican-Peso-
100-obverse.jpg" alt="Moneta">
<button onclick="flipCoin()">Rzuć monetą</button>

<script>
function flipCoin() {
var coin = document.getElementById("coin");
var result = Math.floor(Math.random() * 2);
if (result == 0) {
coin.src =
"https://www.random.org/images/mexican-peso/Mexican-Peso-100-obverse.jpg";
} else {
coin.src =
"https://www.random.org/images/mexican-peso/Mexican-Peso-100-reverse.jpg";
}
}
</script>
</body>
</html>

You might also like