JS noob question about identifying odd number

hallo there,
                if i had a for loop like this (see below) how would i get it to check to see if the value of i was a odd number?

for(i=0;i < 4; i++)
{
 if(i is odd)
 {
   do this code;
 }
}

Cheers

Jack
skinnylAsked:
Who is Participating?
 
eeBlueShadowConnect With a Mentor Commented:
oops, I made mistake #1

if( i % 2 == 1 )
0
 
eeBlueShadowCommented:
if( i % 2 = 1 )
{
...
}

the % sign is the modulo arithmetic operator, and means "the remainder when divided by"

_Blue
0
 
skinnylAuthor Commented:
excellent!

just what i was after.

Ta

Jack
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.