This content has been marked as final.
Show 4 replies

1. Re: Odd and Even numbers
Newsgroup_User Sep 25, 2006 12:54 AM (in response to LSNsaltlamp)to see if even...
if (pageNum % 2 == 0) {
...
}

2. Re: Odd and Even numbers
LSNsaltlamp Sep 25, 2006 8:08 AM (in response to Newsgroup_User)Can you briefly explain how that string works? 
3. Re: Odd and Even numbers
silvermole Sep 25, 2006 8:57 AM (in response to LSNsaltlamp)The part with the %2 means "modulo 2". In effect it is the remainder left after you have divided an integer by 2. Evens will divide and leave no remainder, thus == 0 , or an odd will leave 1 as a remainer (==1). Thus you can determine if number is even fro whats left over , 1 or 2. Dont forget to make sure your numbers are whole integers using Math.round, Math.ceil, or Math.floor. 
4. Re: Odd and Even numbers
Rothrock Sep 25, 2006 9:48 AM (in response to LSNsaltlamp)Actually (assuming pageNum is an integer) I think you can even do this:
if(pageNum % 2){}
Since that will evaluate to either 0 or 1. Zero is False and one is true so. You might need to:
if(Boolean(pageNum % 2)){}