Tebak Angka Code
Tebak Angka Code
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Tebak Angka</title>
<style>
body {
background-color: #f0f0f0;
text-align: center;
padding: 50px;
input[type="number"] {
padding: 10px;
font-size: 16px;
width: 50px;
button {
font-size: 16px;
cursor: pointer;
.result {
margin-top: 20px;
font-size: 18px;
color: green;
.message {
margin-top: 10px;
font-size: 18px;
color: red;
</style>
</head>
<body>
<h1>Tebak Angka!</h1>
<button onclick="checkGuess()">Tebak</button>
<script>
let attempts = 0;
function checkGuess() {
${attempts} percobaan.`;
messageElement.textContent = '';
resetGame();
} else {
function resetGame() {
setTimeout(() => {
attempts = 0;
document.getElementById("guess").value = '';
document.getElementById("result").textContent = '';
document.getElementById("message").textContent = '';
}, 5000);
</script>
</body>
</html>