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

234
Vistas
How to use string.include(substring) to test presence

Suppose there are five words (substring) cat, dog, elephant, tiger, lion and there is a sentence string -- > "We have one cat in our home". Now i need to see which of the substring is present in the string.

So how can we use string.include(substring) to check if any of the substring in present in string and if true which substring is it.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can store the words to find in an array and use Array.filter to filter out the items that aren't included in the string.

const wordsToFind = ['cat', 'dog', 'elephant', 'tiger', 'lion']

const string = "We have one cat in our home";

const includedWords = wordsToFind.filter(e => string.includes(e))
const doesInclude = includedWords.length != 0;

console.log('Does include? ', doesInclude)
console.log('Included words: ', includedWords)

about 4 years ago · Juan Pablo Isaza 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