[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

JS noob question about identifying odd number

Posted on 2004-04-29
3
Medium Priority
?
257 Views
Last Modified: 2008-03-10
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
0
Comment
Question by:skinnyl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Expert Comment

by:eeBlueShadow
ID: 10954437
if( i % 2 = 1 )
{
...
}

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

_Blue
0
 
LVL 10

Accepted Solution

by:
eeBlueShadow earned 200 total points
ID: 10954440
oops, I made mistake #1

if( i % 2 == 1 )
0
 

Author Comment

by:skinnyl
ID: 10954530
excellent!

just what i was after.

Ta

Jack
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question