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

183
Views
¿Cómo obtener el nombre de usuario del título que tiene "eJx2" de esta matriz json?

Quiero obtener el nombre de usuario de uno de estos que tiene "eJx2". Tengo este código, pero este código imprime todos los "nombres de usuario". Solo quiero obtener el nombre de usuario de aquellos que tienen "eJx2".

 var titles = arry.data.map(el => el.title); for (var k in titles) { var never = titles[k].includes('eJx2'); if (never) { var names = arry.data.map(el => el.user_name); console.log(names); } }

y este es el json:

 { data: [ { id: '46475273517', user_name: 'testtwo', title: 'Hello this is my test for the eJx2', is_set: true }, { id: '46471542013', user_name: 'testone', title: 'Hello this is my test for the eJx3', is_set: false }, { id: '46474254233', user_name: 'testthree', title: 'Hello this is my test for the eJx7', is_set: false } ], pagination: { cursor: 'eyJiIjp7IkN1cnNvciI6ImV5SnpJam80TXpBeExqSTBNemcwTVRnME56WTVOQ3dpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In0sImEiOnsiQ3Vyc29yIjoiZXlKeklqbzFOREV1T1RnMk56STNNall5TkRReE5Dd2laQ0k2Wm1Gc2MyVXNJblFpT25SeWRXVjkifX0' } }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Usar filtro de matriz

 array.data.filter(item => item.title.includes("eJx2")) 

 var array = { data: [ { id: '46475273517', user_name: 'testtwo', title: 'Hello this is my test for the eJx2', is_set: true }, { id: '46471542013', user_name: 'testone', title: 'Hello this is my test for the eJx3', is_set: false }, { id: '46474254233', user_name: 'testthree', title: 'Hello this is my test for the eJx7', is_set: false } ], pagination: { cursor: 'eyJiIjp7IkN1cnNvciI6ImV5SnpJam80TXpBeExqSTBNemcwTVRnME56WTVOQ3dpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In0sImEiOnsiQ3Vyc29yIjoiZXlKeklqbzFOREV1T1RnMk56STNNall5TkRReE5Dd2laQ0k2Wm1Gc2MyVXNJblFpT25SeWRXVjkifX0' } } var filteredData = array.data.filter(item => item.title.includes("eJx2")) console.log(filteredData)

about 4 years ago · Juan Pablo Isaza Report

0

Use filter() para filtrar el título, tenga 'eJx2' y map() para obtener solo nombre de user_name :

 const arry = { data: [ { id: '46475273517', user_name: 'testtwo', title: 'Hello this is my test for the eJx2', is_set: true }, { id: '46471542013', user_name: 'testone', title: 'Hello this is my test for the eJx3', is_set: false }, { id: '46474254233', user_name: 'testthree', title: 'Hello this is my test for the eJx7', is_set: false } ], pagination: { cursor: 'eyJiIjp7IkN1cnNvciI6ImV5SnpJam80TXpBeExqSTBNemcwTVRnME56WTVOQ3dpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In0sImEiOnsiQ3Vyc29yIjoiZXlKeklqbzFOREV1T1RnMk56STNNall5TkRReE5Dd2laQ0k2Wm1Gc2MyVXNJblFpT25SeWRXVjkifX0' } } const result = arry.data.filter(({title}) => title.includes("eJx2")).map(el => el.user_name) console.log(result)

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!