modulo operations in an if statement
Jul 31, 2008 at 2:52pm
modulo operations in an if statementHi, I’m totally new to Javascript so sorry if this problem is a bit lame, but I have the following question: I am trying to do some kind of modulo operation in an if statement, but am I correct to note that there is not a predefined modulo operator available in Javascript’s Math object? How would you do it then? To do something like this in C (if it hadn’t a modulo operator that is ofcourse) would be to explicitly cast the 2 operands to integers and then divide them by each other, then multiply the result with the number you divided by and then substract this from the first term. Like for instance: 27%6 = Is something simmilar possible in Javascript? 

Jul 31, 2008 at 3:01pm
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Operators:Arithmetic_Operators Modulo is an arithmetic operator, not part of the Math object. Same as the – Paul On Thu, Jul 31, 2008 at 9:52 AM, Michael Dzjaparidze < > – 

Jul 31, 2008 at 3:07pm
Yes, i see now, how stupid of me… thanks for pointing it out and thanks for the link 
You must be logged in to reply to this topic.