Dinscore Posted December 4, 2021 Posted December 4, 2021 I am trying to add a division button but i can not figure out how to get it work. I've tried adding this to my switch. I think it's the "/" division sign that's not correct. case '4': return currentPayout / (divPayoutLoss) break; Any help would be appreciated.
Skele Posted December 9, 2021 Posted December 9, 2021 no don't return out of your switch, assign a variable and return at the end, much cleaner that way. And since this is javascript you have to know what your variable types are. because if they are both integers your going to lose the remainder in your division. Also make sure you aren't going to divide by 0. It may be cleaner to make it its own method just to throw in the switch statement. var retValue = -1; case '4': retValue = Divide(currentPayout ,divPayoutLoss); break; ...... return retValue; } function Divide(currentPayout, divPayoutLoss) { var retValue = 0; if(divPayoutLoss > 0) { retValue = currentPayout / divPayoutLoss; } }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.