Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
.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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda