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

103
Views
React native, cannot convert function result to number

I need to convert result of this function to number:

const [nbChambres, setNbChambres] = useState(1);
const [nbNuits, setNbNuits] = useState(1); 

function calculatePrixTotal(){
    const nbChambresInt = parseInt(nbChambres) || 1;
    const nbNuitsInt = parseInt(nbNuits) || 1;
    let priceNumber = price.substring(1);

    if(priceNumber.includes(',')) {
        priceNumber = parseInt(priceNumber.replace(',', ''));
        const prixTotal = String(priceNumber * nbNuitsInt * nbChambresInt);
            return prixTotal.slice(0, prixTotal.length - 3) + "," + prixTotal.slice(prixTotal.length - 3);
    } else {
        return String(parseInt(priceNumber) * nbNuitsInt * nbChambresInt);
    }
}

Here is the function I made to make the subtraction, I got NaN as the result:

function calculateNewMoneyBalance(){
    const calcInt = parseFloat(calculatePrixTotal);
    const moneyInt = parseInt(MoneyBalance);
    console.log(typeof moneyInt);
    return parseInt(moneyInt - calcInt);
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hi add method to function call

let calcInt= parseFloat(calculatePrixTotal())

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!