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

186
Views
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 answers
Answer question

0

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

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!