EatTheBlocks Forum

Issue calling solidity function in a js function

I’m working on a personal project, i’m trying to use some functions in my solidity code to do some calculation. Below are my code,

function checkPoolForDistribution() {
      let stakeholdersCountBeforeUpdate;
      let currentStakeholdersCount;
      let totalStakeingPool;
      staking.methods.stakeholdersCount().call()
        .then(result => {  
          stakeholdersCountBeforeUpdate = result
        })
      staking.methods.callAddTodayCount().call()
        .then(result => {  
          currentStakeholdersCount = result
        })
      let newStakers = currentStakeholdersCount - stakeholdersCountBeforeUpdate;
      let f = newStakers * 100;
      let percentGrowth = f/(stakeholdersCountBeforeUpdate);
      staking.methods.updatePercent(percentGrowth).call();
        if(percentGrowth >= 10){
          staking.methods.totalStakeingPool().call()
          .then(result => { totalStakeingPool = parseIntresult
          })
          let w = totalStakeingPool * percentGrowth;
          let getPoolToShare = w / 1000;
          totalStakeingPool = totalStakeingPool - getPoolToShare;
          staking.methods.updateStakingPool(totalStakeingPool).send({from: accounts[0]});
        rewardToShare = getPoolToShare;
    }
}
distribute.addEventListener('click',(e) => {
    e.preventDefault();
    checkPoolForDistribution()
    .then(result => {
      distributeResult.innerHTML = `successful`;
    })
    .catch(() => {
      distributeResult.innerHTML = `error`;
    }); 
  });

when I click the distribute button i get this error

index.js:171 Uncaught Error: invalid BigNumber string (argument="value", value="NaN", code=INVALID_ARGUMENT, version=bignumber/5.0.5)```

how can I rectify this thanks

This may help