Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

You can parse to get the desired solution

JSON.parse(location)

about 4 years ago · Juan Pablo Isaza Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda