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

170
Views
esperaba un identificador en lugar de ver '('. esperaba un identificador en lugar de ver ')'

Estoy usando la ordenación de burbujas para ordenar una matriz, pero cuando escribo la función de intercambio, recibo un error al escribir la función de línea swap(arr,j,j+1) Obtengo el error "esperado ')' para que coincida con ' ('

 function solve(N, arr){ for (var i = 0; i < N; i++){ for(var j = 0; j < (N - i - 1); j++){ if (arr[j] > arr[j + 1]) { swap(arr, j, j + 1) } } } function swap(arr,j,j+1) //getting error here "expected a identifier instead saw '('. expected a identifier instead saw ')'. "[look at the screenshot ][1] { var temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El problema es que tienes una expresión j+1 como parámetro en tu función.

 function swap(arr, j, j + 1)

No puede hacer eso, o cambia el nombre j + 1 a k , por ejemplo. Pero, ¿por qué incluso enviarlos a ambos en primer lugar si k = j + 1 ? Podrías lograr esto usando solo

 function swap(arr,j) { var temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; }

y llamando a la función como

 swap(arr,j);
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!