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

178
Views
the value in the function becomes NAN

I'm just learning. Why does the 'tarifComm' value that I pass to the 'calcCondition' function become NaN. it doesn't let me calculate. how can i fix this problem?

input data

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

array

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"
}]

function dividing the calculation into parts

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()

and calculation function

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!