JSFiddle - React, Tailwind, and code Playground
by Prathameshsb
HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Coin Flip</h1>
<button id="flip-button" onclick="flipCoin()">Flip</button>
<div id="result"></div>
<script src="script.js"></script>
</body>
</html>
CSS
body {
text-align: center;
}
h1 {
color: #333;
}
button {
padding: 10px 20px;
font-size: 18px;
background-color: lightgreen;
color: #fff;
border: 2px solid darkgreen;
cursor: pointer;
}
#result {
margin-top: 20px;
font-size: 24px;
font-weight: bold;
}
JavaScript
function flipCoin() {
var resultElement = document.getElementById("result");
var outcome = Math.random() < 0.5 ? "Heads" : "Tails";
resultElement.innerText = "Result: " + outcome;
}