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

237
Views
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 answers
Answer question

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 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!