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

271
Views
¿Por qué este código javscript da como resultado undefined? (Calculando GCD), no se porque no entra si bloque

No sé por qué no está ingresando si está bloqueado. Tal vez por el tipo de coerción. Corríjame y dígame cuál es el error en este código.

 function calculateGCD(a, b) { if (b === 0) { return a; } else console.log(a, b); a > b ? calculateGCD(b, (a % b)) : calculateGCD(a, (b % a)); } function main() { let n1, n2, gcd; n1 = +prompt("enter 1st number?"); n2 = +prompt("enter second number?"); gcd = calculateGCD(n1, n2); document.write(gcd); } main();

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En la función debes devolver el resultado.

 function calculateGCD(a, b) { let result if (b === 0) { return a; } else { console.log(a, b); a > b ? result = (b, (a % b)) : result = (a, (b % a)); } return result }
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!