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

94
Views
Analizando la cadena de JavaScript en 2 matrices

Tiene una cadena que tiene el siguiente formato: "Applejack=AJ+Applecar,Lemon+Vodka=AlfieCocktail+ Sunset + SexOnTheBeach", etc.

En Javascript (use .split()), escriba código para analizar una cadena como esta (puede tener 100000 caracteres) que coloca la entrada en 2 matrices diferentes (clave de matriz, valores de matriz) de modo que las matrices se verían así:

tecla = ["Applejack", "Limón+Vodka"]

valores = ["A.J+Applecar","AlfieCocktail+Sunset+SexOnTheBeach"]

about 4 years ago · Santiago Gelvez
3 answers
Answer question

0

key = string.split(',').map(x=>x.split("=")[0]) values = string.split(',').map(x=>x.split("=")[1])
about 4 years ago · Santiago Gelvez Report

0

Podrías hacer algo como esto

 var str = "Applejack=AJ+Applecar,Lemon+Vodka=AlfieCocktail+ Sunset + SexOnTheBeach"; var first = str.split(','); var keys = []; var values = []; for(let i = 0; i < first.length; i++){ let in_two = first[i].split('='); keys.push(in_two[0]); values.push(in_two[1]); } console.log(keys); console.log(values);
about 4 years ago · Santiago Gelvez Report

0

Puedes hacerlo así:

 let str = "Applejack=AJ+Applecar,Lemon+Vodka=AlfieCocktail+ Sunset + SexOnTheBeach"; let allValues = str.split(','), keys = [], values = []; allValues.forEach(value => { const [k,v] = value.split('='); keys.push(k); values.push(v); }) console.log(keys,values);

about 4 years ago · Santiago Gelvez 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!