LESSON 39 OF 50

Search an array with includes

Check whether an array contains a specific value.

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

How it works

Array.prototype.includes compares elements with the searched value and returns a boolean.

Correct example
const services = ['Design', 'Dezvoltare', 'SEO'];
const hasSeo = services.includes('SEO');
console.log(hasSeo);

SEO exists in the collection, so the result is true.

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

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

STEP 2 · APPLY

Your exercise

Store services.includes(“SEO”) in hasSeo and print the result.

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
  • services contains the required values.
  • hasSeo receives services.includes(“SEO”).
  • The output is exactly true.
Explain the solution logic

The search is tied to the real collection, and the output reflects the method result.