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

232
Views
For loop y declaración If en una lista de secuencias de comandos de aplicaciones de Google

Soy amigable con Python, pero necesito el mismo código en el script de aplicaciones de Google. (el código está debajo del texto)

Gracias de antemano

Necesito mi salida como esta:

más = [[600, 'ter', 'simple'], [600, 'ter', 'simple']]

Aquí está mi código:

 function myFunction() { var data =[[600, 'ter', 'simple'], [600, 'ter', 'simple'], [300, 'ter', 'medium'], [200, 'ter', 'Hard']] var plus = [] for (let i = data[0]; i < data.leng; i++) { if ( data[i][0] == data[0][0]) { plus.push(data) } } }
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Un par de errores de sintaxis aquí y allá. Los señaló en código:

 /*<ignore>*/console.config({maximize:true,timeStamps:false,autoScroll:false});/*</ignore>*/ function myFunction() { var data = [ [600, 'ter', 'simple'], [600, 'ter', 'simple'], [300, 'ter', 'medium'], [200, 'ter', 'Hard'], ]; var plus = []; for ( let i = 0 /* intializer or counter should start with 0 not data[0] */; i < data.length /* No property named leng data.leng */; i++ ) { if (data[i][0] == data[0][0]) { plus.push( data[ i ] /* push only the current element `data[i]` and not the full `data` array */ ); } } console.log(plus); } myFunction();
 <!-- https://meta.stackoverflow.com/a/375985/ --> <script src="https://gh-canon.github.io/stack-snippet-console/console.min.js"></script>

about 4 years ago · Santiago Trujillo Report

0

Usa Array.filter() , así:

 function filterData() { const data = [ [600, 'ter', 'simple'], [600, 'ter', 'simple'], [300, 'ter', 'medium'], [200, 'ter', 'Hard'], ]; const filterBy = { column: 0, value: data[0][0] }; return data.filter(row => row[filterBy.column] === filterBy.value); }
about 4 years ago · Santiago Trujillo 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!