LESSON 33 OF 50

Check text with includes

Find out whether a string contains an exact sequence.

Official sourceECMAScript — String.prototype.includesReviewed: 2026-08-26
STEP 1 · LEARN

How it works

String.prototype.includes searches for the supplied text and returns true or false. The search is case-sensitive.

Correct example
const title = 'curs web practic';
const hasWeb = title.includes('web');
console.log(hasWeb);

The “web” sequence exists in title, so the method returns true.

Common mistake
const hasWeb = true;
console.log(hasWeb);

The boolean is hard-coded and does not inspect the string.

STEP 2 · APPLY

Your exercise

Check whether title contains “web”, store the result in hasWeb and print it.

STEP 3 · RUN

Write and run the code

script.jsJAVASCRIPT
Isolated consoleisolated
Preparing the runtime…
Run the code to see the result.
The draft stays only in this browser.Isolated QuickJS · no DOM, session or network
STEP 4 · CHECK

What needs to pass

0%not checked
  • title is declared with const.
  • hasWeb receives title.includes(“web”).
  • The output is exactly true.
Explain the solution logic

The method performs the real search, and the variable stores the boolean result.