Skip to content
Advertisement

Getting Math domain Error but it is not because of negative values

So I am trying to make a tower defense game and I tried to make a back button and before it worked but now when I try it gives me a math domain error. I’ve seen online it may come if I take something like the root of -1 but that’s not possible because the value is being squared. It happens in CheckClicked function under Class Back_Button. Can anybody figure it out?

JavaScript

Advertisement

Answer

It looks like you misplaced a parenthesis in the second squared term. This is what you have now:

JavaScript

Instead of that, try moving the closing parenthesis to before the exponential:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement