<header>
<h2 class="title">Number.isNaN()</h2>
<p class="description">Перевірка значення на NaN</p>
</header>
<main>
<div class="result">
<input type="text" id="inputValue" placeholder="Введіть значення для перевірки">
<button onclick="checkNaN()">Перевірити</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);
}
#inputValue {
padding: 10px;
margin-right: 10px;
}
button {
padding: 10px 15px;
cursor: pointer;
border: none;
background-color: #4CAF50;
color: white;
}
function checkNaN() {
const inputValue = document.getElementById('inputValue').value;
const output = document.getElementById('output');
if (Number.isNaN(Number(inputValue))) {
output.innerHTML = "Результат: це NaN!";
} else {
output.innerHTML = "Результат: це не NaN!";
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.