<header>
<h2 class="title">Math.max()</h2>
<p class="description">Повертає найбільше значення серед переданих аргументів.</p>
</header>
<main>
<div class="result">
<label for="numbers">Введіть числа через кому:</label>
<input type="text" id="numbers" placeholder="наприклад: 1, 5, 8, 9">
<button onclick="findMax()">Знайти найбільше</button>
<p id="output"></p>
</div>
</main>
body {
font-size: 16px;
line-height: 1.5;
font-family: monospace;
}
header {
background-color: #f1f1f1;
margin-bottom: 25px;
padding: 15px;
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
}
header h2.title {
padding-bottom: 15px;
border-bottom: 1px solid #999;
}
header p.description {
font-style: italic;
color: #222;
}
.result {
background-color: #f8f8f8;
padding: 15px;
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
}
input[type="text"] {
padding: 10px;
margin: 10px 0;
display: block;
width: 250px;
}
button {
padding: 10px 15px;
background-color: #007BFF;
color: #FFF;
border: none;
cursor: pointer;
transition: 0.3s;
}
button:hover {
background-color: #0056b3;
}
function findMax() {
const numbersInput = document.getElementById('numbers').value;
const numberArray = numbersInput.split(',').map(num => parseFloat(num));
const maxNumber = Math.max(numberArray);
document.getElementById('output').innerText = "Найбільше число: " + maxNumber;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.