Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
.includes with array in Javascript

i wonder is there any way to check if in a string there are characters that match the characters in array?

const array = ["cake","hello","ok"];
const string = "hello"
let result = string.includes(array)
console.log(result)
// >false
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Try to switch array and string:

const array = ["cake","hello","ok"];
const string = "hello"
let result = array.includes(string)
console.log(result)

about 4 years ago · Santiago Trujillo Report

0

I think you're looking for Array#some(): loop through the array and check if any of the elements match the predicate.

Here checking if string includes as a substring any of the strings in array.

const array = ["cake","hello","ok"];
const string = "helloaeeahwbdhbd"
let result = array.some(s => string.includes(s))
console.log(result)

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!