Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

0

You can parse to get the desired solution

JSON.parse(location)

about 4 years ago · Juan Pablo Isaza Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda