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

304
Views
How would you rewrite Brad's code to use the split method instead and what bug is in the code?

I am trying to learn JavaScript and currently stuck on a question about how would I rewrite brad's code using the split method and bug does brad have in his code? can you please help? Here is the code

function validate(phoneNumber) { 
  if (phoneNumber.length > 8 ||
      phoneNumber.length < 7) {
      return false;
  }
  var first = phoneNumber.substring(0,3);
  var second = phoneNumber.substring(phoneNumber.length - 4);
  
  if (isNaN(first) || isNaN(second)) {
  return false;
  }
  if (phoneNumber.length === 8) {
     return (phoneNumber.charAt(3) === "-");
  } 
  return true;

}

var number= validate("123-6778");
console.log(number);

Page the question and the code is on

about 4 years ago · Juan Pablo Isaza
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!