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

128
Views
padStart() targetLength is not met

const id = 46919;
const string = id.toString(36); // output: "107b"

console.log(string.padStart(3, '0'));

The expected output of the console.log() would be 107 since the targetLength of method padStart() is equal to 3, but the actual output is 107b which is a total of 4 characters.

Would you know why this happens please?

Edit: I misunderstood the use of this method, I thought it would cut the extra characters like slice()

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

0

Maybe you can use parseInt() in the end of code

const id = 46919;
const string = id.toString(36);
console.log(parseInt(string.padStart(3, '0')));
//output 107
about 4 years ago · Juan Pablo Isaza Report

0

the toString(36) converts the number to base 36 from base 10, 46919 is 107b in base 36. padStart will add characters until the length is equal to the first parameter. Since 107b is already 4 characters it doesn't do anything.

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!