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

200
Vistas
Data Saved as Strings, But need Ints

I am retrieving data from a table. The data is numbers, but it was saved as TINYTEXT in the mySql database. I can retrieve it and access it just fine, but I'm running into trouble because I need to add numbers.

So while I want 4 + 5 + 3 = 12.... instead I get the result of "453".

This is my calculation on the retrieved data:

let consultingScore = 0;
let consultingScoreDiv = 0;
   for (let i = 0; i < result.length; i++){
   let tempConScore = result[i].formValue01 + 
   result[i].formValue02 + result[i].formValue03;

   consultingScore = consultingScore + tempConScore;

   this.setState({ surveyScoreConsulting: consultingScore }); <--- (This should be 12, but is instead "453"
                }

I have tried to use parseInt() like below, but when I do, then the value then becomes NaN. Am I not using parseInt correctly? It seems it should be easier than this to convert sting numbers to integers so I can perform calculations with them.

let consultingScore = 0;
let consultingScoreDiv = 0;
   for (let i = 0; i < result.length; i++){
   let tempConScore = parseInt(result[i].formValue01) + 
   parseInt(result[i].formValue02) + parseInt(result[i].formValue03);

   consultingScore = consultingScore + tempConScore;

   this.setState({ surveyScoreConsulting: consultingScore }); <--- (This should be 12, but is instead "453"
                }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try to parse with base 10, like this parseInt(yourValue, 10)

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