Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot read properties of undefined (reading 'toString')

I’m currently trying to parse anonymous functions and am currently getting the error as per the title. I’ve tested a few things, and the core math works, but there’s an issue with parsing the information. Any help is appreciated.

In this instance, manaCost = 10 and manaLevel = 0

if(manaLevel>=1){
manaCost = increase(5,manaCost,1.17,manaLevel);
} else {
manaCost = increase(5,manaCost,1.17,1);
}
function increase(n,b,r,k){
    b * (Math.pow(r,k)*((Math.pow(r,n)-1)/(r-1)));
}

The core math of

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

manaCost * (Math.pow(1.17,1)*((Math.pow(1.17,5)-1)/(1.17-1)))

functions.

>Solution :

You need to return a value in your functions if you want to assign something to the return value of the function. Otherwise it returns undefined.

function increase(n,b,r,k){
    return b * (Math.pow(r,k)*((Math.pow(r,n)-1)/(r-1)));
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading