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

173
Views
el valor en la función se convierte en NAN

Yo sólo estoy aprendiendo. ¿Por qué el valor 'tarifComm' que paso a la función 'calcCondition' se convierte en NaN? no me deja calcular ¿Como puedo solucionar este problema?

datos de entrada

 const input = 700000, const step = 3, let tarifComm = 0, let tempInput = input

formación

 const mass = [ { "step": "1", "min": "0", "max": "150000", "percent": "0.75", "fix": "79" }, { "step": "2", "min": "150001", "max": "500000", "percent": "1.5", "fix": "79" }, { "step": "3", "min": "500001", "max": "2000000", "percent": "2.5", "fix": "79" }, { "step": "4", "min": "2000001", "max": "99999999", "percent": "4", "fix": "79" }]

función que divide el cálculo en partes

 function calcStep() { for(let i = 0; i < step; i++) { console.log(`комиссия в начале пути ${tarifComm}`) console.log(`создан ${tempInput}`) if (tempInput > mass[i].max) { tarifComm += calcCondition(i, tarifComm) console.log(`комиссия на ${i+1} шаге: ${tarifComm}`) tempInput = tempInput - mass[i].max console.log(`изменен в макс ${tempInput}`) } else if (tempInput < mass[i].max) { console.log(`комиссия в мин: ${tarifComm}`) console.log(`остаток в мин ${tempInput}`) tarifComm += tempInput / 100 * mass[i].percent } } tarifComm += Number(mass[step].fix)} calcStep()

y función de cálculo

 function calcCondition(i, tarifComm) { console.log(`комиссия попавшая в расчет ${tarifComm}`) if (mass[i].free && !mass[i].percent) { tarifComm += 0 } else if (!mass[i].free && mass[i].percent) { tarifComm += mass[i].max / 100 * mass[i].percent }}
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!