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

83
Views
La función iisTidy (número) no da el resultado deseado

 function isTidy(number) { let str = number.toString(); for (let i = 1; i < str.length; i++) { if (str.charAt(i) < str.charAt(i + 1)) { return true; } if (str.charAt(i) > str.charAt(i + 1)) { return false; } if (str.charAt(i) == str.charAt(i + 1)) { return false; } } } console.log(isTidy(135587));

Cómo tiene que funcionar:

está ordenado(12) ==> verdadero

Los números { 1, 2 } están en secuencia no decreciente, es decir, 1 <= 2.

está ordenado(32) ==> falso

Los números { 3, 2 } están en orden descendente, es decir, 3 > 2.

está ordenado(1024) ==> falso

Los números { 1, 0, 2, 4 } están en orden descendente porque 0 < 1.

está ordenado (3445) ==> verdadero

Los números { 3, 4, 4, 5 } están en secuencia no decreciente, porque 4 <= 4.

está ordenado (13579) ==> verdadero

Los números {1, 3, 5, 7, 9} están en orden ascendente.

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

0

También debe verificar el dígito anterior y salir temprano si el número no es igual o aumenta.

Al final devuelve true .

 function isTidy(number) { let str = number.toString(); for (let i = 1; i < str.length; i++) { if (str[i - 1] > str[i]) return false; } return true; } console.log(isTidy(135578)); console.log(isTidy(135587));

about 4 years ago · Juan Pablo Isaza Report

0

 function isTidy(number) { let str = number.toString(); for (let i = 1; i < str.length; i++) { let nextNumber = str.charAt(i + 1); if (nextNumber != "" && str.charAt(i) > nextNumber) return false; } return true; } console.log(isTidy(135587));

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!