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

154
Views
How to search a value and replace in array?

What i need is just replace a specific value in my array, not it all. Exemple:

let ARRAY = ['asd dsa', 'asd', 'dsa asd', 'abc']

I need to remove the words "asd" and replace to "abc" like:

 ['abc dsa','abc','dsa abc','abc']

My attempt:

ARRAY.replace(/asd/g, 'abc');

but not even in array this works. there is some way to make it?

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

0

Map the array to a new array, and call .replace (or, more appropriately, .replaceAll) on every item.

const input = ['asd dsa', 'asd', 'dsa asd', 'abc'];
const result = input.map(
  str => str.replaceAll('asd', 'abc')
);
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!