P5.js code for creating a calculator tip app confused

Your calculation() function seems to only be defined in the scope of the draw() function. So When you call it outside of the draw function, it does not exist.