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

258
Views
¿Cómo puedo obtener el valor correctamente con split?

Estoy tratando de obtener el valor ingresado por el usuario y cada vez que cambia este valor redimido también se cambia, pero cuando pongo un valor pequeño: R $ 5,00 no pasa nada, solo acepta un valor alto: 400,00 y la devolución es un absurdo 40,000.00. Cuando trato de poner un valor pequeño, ocurre el siguiente error de NaN

 const {valueAmount, textDescription} = props.navigation.state.params; const amoutSplit = valueAmount.split('R$ '); const includComma = amoutSplit[1].split(','); const amout = Number(includComma[0] + includComma[1]);
 <Text>{Filters.convertMoneyTextMask(amout)} </Text>

la máscara

 const convertMoneyTextMask = (value) => { if (value) { const stringOnlyNumbers = `${Number(value).toFixed(2)}`.replace(/\D/g, ''); if (!stringOnlyNumbers) { return 'R$ 0,00'; } const {length} = stringOnlyNumbers; if (length === 1) { return value >= 0 ? `R$ 0,0${stringOnlyNumbers}` : `R$ -0,0${stringOnlyNumbers}`; } if (length === 2) { return value >= 0 ? `R$ 0,${stringOnlyNumbers}` : `R$ -0,${stringOnlyNumbers}`; } let moneyMask = ''; for (let i = length - 1; i >= 0; i -= 1) { if (i === length - 2) { moneyMask = `,${stringOnlyNumbers[i]}${moneyMask}`; } else if (i < length - 5 && (i - length - 3) % 3 === 0) { moneyMask = `${stringOnlyNumbers[i]}.${moneyMask}`; } else { moneyMask = `${stringOnlyNumbers[i]}${moneyMask}`; } } return value >= 0 ? `R$ ${moneyMask}` : `R$ -${moneyMask}`; } return 'R$ 0,00'; };
about 4 years ago · Juan Pablo Isaza
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!