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

205
Views
¿Cómo puedo verificar una matriz de matrices para ver si una matriz interna tiene ambos valores mayores que los valores de la anterior?

He venido a este código, pero da como resultado un error. La idea es tener, al final del programa, un arreglo de arreglos con todos los arreglos originales que cumplan la condición de tener ambos valores mayores que los valores del arreglo anterior.

 var data = [[68, 150], [70, 155], [55, 160]]; var result = []; for(i=0; i<data.length; i++){ var firstPosterior = data[i+1][0]; var lastPosterior = data[i+1][1]; var firstAnterior = data[i][0]; var lastAnterior = data[i][1]; if( firstPosterior > firstAnterior && lastPosterior > lastAnterior ) { result.push(firstPosterior, firstPosterior); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Primero tienes un error de compilación en

 for(i=0; i<data.length; i++) // i is not defined. You should use let, var to declare it

Aquí está un ejemplo

 var data = [[68, 150], [70, 155], [55, 160]]; var result = []; for(let i=0; i<data.length -1; i++){ var firstPosterior = data[i+1][0]; var lastPosterior = data[i+1][1]; var firstAnterior = data[i][0]; var lastAnterior = data[i][1]; if( firstPosterior > firstAnterior && lastPosterior > lastAnterior ) { result.push(data[i+1]); } }

Estoy agregando en el resultado solo matrices que cumplieron con la condición.

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!