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

122
Views
¿Cómo divido y elimino el espacio en blanco de este objeto de latitud y longitud?

Estos son números aleatorios para la privacidad.

Deben dividirse por la coma y colocarse en sus propias constantes

 { '0': '2', '1': '5', '2': '.', '3': '1', '4': '3', '5': '4', '6': '2', '7': '0', '8': '0', '9': ',', '10': ' ', '11': '-', '12': '3', '13': '8', '14': '.', '15': '5', '16': '4', '17': '9', '18': '2', '19': '0', '20': '2' }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puede usar Object.values para obtener una matriz, luego unirla y dividirla por coma. Finalmente, convierta las partes divididas en número:

 const data = {'0': '2','1': '5','2': '.','3': '1','4': '3','5': '4','6': '2','7': '0','8': '0','9': ',','10': ' ','11': '-','12': '3','13': '8','14': '.','15': '5','16': '4','17': '9','18': '2','19': '0','20': '2'}; const [long, lat] = Object.values(data).join("").split(",").map(Number); console.log(long, lat);

about 4 years ago · Juan Pablo Isaza Report

0

Iba a sugerir lo siguiente, pero la respuesta de Trincot es mucho mejor.

 const data = {'0': '2','1': '5','2': '.','3': '1','4': '3','5': '4','6': '2','7': '0','8': '0','9': ',','10': ' ','11': '-','12': '3','13': '8','14': '.','15': '5','16': '4','17': '9','18': '2','19': '0','20': '2'}; const convertArrayItemsToInt = (digist_array) => { return parseFloat( digist_array.reduce((complete_number, currentDigit) => { if (!isNaN(parseInt(currentDigit)) || currentDigit == ".") { complete_number += currentDigit; } return complete_number; }, "") ); }; //Get only the values const coordinates = Object.values(data); //Get the comma index const comma_index = coordinates.indexOf(","); //Split the array by the comma and give it to convertArrayItemsToInt const lat = convertArrayItemsToInt(coordinates.slice(0, comma_index)); const lng = convertArrayItemsToInt( coordinates.slice(comma_index, coordinates.length) );
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!