Dynamic Drive Forums
>
General Coding
>
JavaScript
> Distinguishing # types
PDA
View Full Version :
Distinguishing # types
helpless
12-18-2006, 06:08 PM
How do you distinguish between numbers that are add and even in javascript? i searched a whole jscript book and web for it but couldn't find any info.
Twey
12-18-2006, 08:30 PM
Find the remainder when divided by two.if(n % 2 === 0)
// n is even
else
// n is odd
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.