Dynamic Drive Forums
>
General Coding
>
JavaScript
> Distinguishing # types
Log in
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
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.