<header>
  <h2 class="title">String.prototype.includes()</h2>
  <p class="description">Перевіряє, чи містить рядок заданий підрядок.</p>
</header>
<main>
  <div class="result">
    <input type="text" id="inputText" placeholder="Введіть текст тут...">
    <input type="text" id="substring" placeholder="Підрядок для пошуку...">
    <button onclick="checkSubstring()">Перевірити</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;
  -webkit-box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
  -moz-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;
  -webkit-box-shadow: 0px 0px 3px 0px rgba(118, 118, 118, 1);
  -moz-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"] {
  margin: 10px 0;
  padding: 5px;
  width: 80%;
}

button {
  cursor: pointer;
  padding: 5px 10px;
}
function checkSubstring() {
  const text = document.getElementById('inputText').value;
  const substring = document.getElementById('substring').value;
  const result = text.includes(substring);
  document.getElementById('output').innerText = `Підрядок "${substring}" ${result ? 'знайдено' : 'не знайдено'} у тексті.`;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.