Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda