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

141
Views
How do I remove an array from a string?

Here is the code

location: '["41.8481","-72.0345"]'

Here is what I tried

location.replace(/'/g,'');

This is what I want

location: ["41.8481","-72.0345"]

Any help would be appreciated

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

0

You can parse the string to an array using JSON.parse

const loc = '["41.8481","-72.0345"]';
const locArr = JSON.parse(loc);
console.log(locArr);

about 4 years ago · Juan Pablo Isaza Report

0

You can parse to get the desired solution

JSON.parse(location)

about 4 years ago · Juan Pablo Isaza Report

0

first off, i have no idea why you might do this. if you want to edit an array and put it into a string, and then get the array again, just split it with a character. one thing that you could do is this:

let hello = "a|b|c|d|e|f|g";
console.log(hello.split("|")[0]);
//result: "a"

or use JSON.parse. it's easy as 1, 2,

console.log(JSON.parse(location));
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!