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

180
Views
Capturing only part of the string to be recognized in if conditional

Is there a way to just capture part of a string in an if conditional?

var armadilloRoles = [
  { name: 'Billing', description: 'armadillo.organization.billing' },
  { name: 'Doctor', description: 'armadillo.organization.doctor' },
    { name: 'Nurse Practitioner', description: 'armadillo.organization.nursePractitioner' },
  { name: 'Patient', description: 'armadillo.organization.patient' },
  { name: 'Aluna admin', description: 'armadillo.microurb.admin' },
    { name: 'Aluna billing', description: 'armadillo.microurb.billing' },
    { name: 'Respiratory therapist', description: 'armadillo.microurb.respiratoryTherapist' },
    { name: 'Aluna commercial contact', description: 'armadillo.microurb.practiceGrowthDirector' }
];

var viewRoles = [];

for (var i = 0; i < armadilloRoles.length; i++) {
    if (armadilloRoles[i].description === 'armadillo.organization.') {
    viewRoles.push(armadilloRoles[i]);
  }
}

viewRoles;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There are several string methods which could be employed. In your case, you're searching for a substring at the beginning of matching description strings, so the .startsWith method will work just fine.

var armadilloRoles = [
  { name: 'Billing', description: 'armadillo.organization.billing' },
  { name: 'Doctor', description: 'armadillo.organization.doctor' },
  { name: 'Nurse Practitioner', description: 'armadillo.organization.nursePractitioner' },
  { name: 'Patient', description: 'armadillo.organization.patient' },
  { name: 'Aluna admin', description: 'armadillo.microurb.admin' },
  { name: 'Aluna billing', description: 'armadillo.microurb.billing' },
  { name: 'Respiratory therapist', description: 'armadillo.microurb.respiratoryTherapist' },
  { name: 'Aluna commercial contact', description: 'armadillo.microurb.practiceGrowthDirector' }
];

var viewRoles = [];

for (var i = 0; i < armadilloRoles.length; i++) {
  if (armadilloRoles[i].description.startsWith('armadillo.organization.')) {
    viewRoles.push(armadilloRoles[i]);
  }
}

console.log(viewRoles);

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!