<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Бросок кубика 3 раза</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}
button {
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
}
#result {
font-size: 24px;
font-weight: bold;
margin-top: 20px;
color: green;
}
</style>
</head>
<body>
<h1>Генератор трехзначного числа</h1>
<p>Нажмите на кнопку, чтобы бросить кубик (от 1 до 6) три раза!</p>
<button onclick="brositKubik()">Бросить кубик</button>
<div id="result"></div>
<script>
function brositKubik() {
// Умножаем на 6, чтобы выпадали только цифры от 1 до 6
let blesk1 = Math.floor(Math.random() * 6) + 1;
let blesk2 = Math.floor(Math.random() * 6) + 1;
let blesk3 = Math.floor(Math.random() * 6) + 1;
// Склеиваем цифры в один текст
let itogovoeChislo = String(blesk1) + String(blesk2) + String(blesk3);
// Выводим результат на экран
document.getElementById("result").innerHTML =
"Выпало: " + blesk1 + ", " + blesk2 + ", " + blesk3 + "<br>" +
"Получилось число: " + itogovoeChislo;
}
</script>
</body>
</html>