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

196
Views
cambie todos los elementos de mi matriz repitiendo el último que agregué

cuando trato de agregar el nuevo elemento a la matriz, cambia el resto de los elementos repitiendo el último que agregué. Estoy aprendiendo a programar en java script y encontré este error, no porque ocurra. ¿Alguien me lo puede explicar?

 input=`^>v<` input=input.split("") var coordinates=[0,0] var positions=[] y=0 v=0 for (x in input){ v+=1 x=input[x] if (x=="^"){ coordinates[1]+=1 } if (x=="v"){ coordinates[1]-=1 } if (x==">"){ coordinates[0]+=1 } if (x=="<"){ coordinates[0]-=1 } boolean=positions.indexOf(coordinates) positions.push(coordinates) console.log(coordinates) } console.log(positions)

producción

 [ [ 0, 1 ] ] [ [ 1, 1 ], [ 1, 1 ] ] [ [ 1, 0 ], [ 1, 0 ], [ 1, 0 ] ] [ [ 0, 0 ], [ 0, 0 ], [ 0, 0 ], [ 0, 0 ] ] [ [ 0, 0 ], [ 0, 0 ], [ 0, 0 ], [ 0, 0 ] ]
about 4 years ago · Juan Pablo Isaza
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!