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

170
Views
Trying to return just the description in an array of instances of a class

So this is what I am trying to solve:

class ViewRole {
  name
  description
  constructor(name, description) {
    this.name = name;
    this.description = description;
  }
}

class NewRole {
  name;
  description;
  constructor(name, description) {
    this.name = name;
    this.description = description;
  }
}

var armadilloRoles = [
  new NewRole('Billing', 'armadillo.organization.billing'),
  new NewRole('Doctor', 'armadillo.organization.doctor'),
  new NewRole('Nurse Practitioner', 'armadillo.organization.nursePractitioner'),
  new NewRole('Patient', 'armadillo.microurb.billing'),
  new NewRole('Microurb admin', 'armadillo.organization.admin'),
  new NewRole('Microurb admin', 'armadillo.organization.admin'),
  new NewRole('Microurb billing', 'armadillo.organization.billing'),
  new NewRole('Respiratory therapist', 'armadillo.microurb.respiratoryTherapist'),
  new NewRole('Microurb commercial contact', 'armadillo.microurb.practiceGrowthDirector')
];

var viewRoles = [];

for (var i = 0; i < armadilloRoles.length; i++) {
  const role = armadilloRoles[i];
  const viewRoleDto = new ViewRole(role.name, role.description);
  //  if (viewRoleDto[i].description.startsWith('armadillo.organization.')) {
  //      viewRoles.push(viewRoleDto[i]);
  //  }
  viewRoles.push(viewRole);
}
console.log(viewRoles);

I have tried a variety of ways of implementing an if conditional with a startsWith() method.

I want to return just the ones that have armadillo.organization. as the description.

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

0

A good way would be to use reduce like this:

const matches = armadilloRoles.reduce(
  (prev, cur) =>
    cur.description.startsWith("armadillo.organization") ? [...prev, cur] : prev,
  []
);
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!