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
la verificación del número de teléfono devuelve falso cuando debería devolver verdadero y no puedo encontrar dónde se estropea

Estoy completando un proyecto de verificador telefónico y puedo identificar correctamente los resultados falsos, pero los verdaderos no son verdaderos.

Aquí está mi código hasta ahora. Revisé las funciones individuales y todas parecen funcionar, aunque no tengo conocimiento de cómo verificar errores además de eso. ¡Cualquier sugerencia es bienvenida!

 function telephoneCheck(str) { let newStr = str; let numberOfNumbers = 0; if (newStr.match(/[!^A-Za-z!@#$%^&*_+=<>,.:]/gm) == []) { for (let i = 0; i < newStr.length; i++) { if (!isNaN(newStr[i])) { numberOfNumbers += 1; } } if (numberOfNumbers == 10) { return true; } else if (newStr[0] == 1) { return true; } else { return false; } } else { return false; } } console.log(telephoneCheck("555-555-5555"));

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

0

Muchos problemas. No puedes comparar una matriz con otra matriz, nunca son iguales

Esto es lo que creo que querías

 const notNumDash= /[^\-0-9]/g; // something other than numbers and dashes const telephoneCheck = str => { if (notNumDash.test(str)) return false; const numberOfNumbers = str.replace(/[^0-9]/g, ''); // remove all not numbers return numberOfNumbers.length === 10 || numberOfNumbers[0] == 1; // either or returns true, all others false } console.log("555-555-5555",telephoneCheck("555-555-5555")); console.log("5XXX55-555-5555",telephoneCheck("5XXX55-555-5555"));

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!