A look at If, Else logic.

26. October 2009 21:03

I was browsing some of my last post and I saw I that I used a few “If” statements, but I didn’t mention anything on the “IF, ELSE” structure. This condition checking structure is used throughout most programming languages. And aside with looping is essential to a computer’s functioning. The scenario is that a condition will be checked in the “If” line of the statement. If that condition is true, then the code within it’s brackets will be executed. Otherwise nothing will happen. If there is and “Else” statement after the “If” statement, then that code will be executed if the “If” statement is false. There is also the “Else If” statement to further add conditions to be checked.

For example:

var x = 9;

if( x ==9)

{

 document.write(x);

}

X is equal to nine, so the condition is true and the value of variable x will be printed on the screen.

var x = 9;

if( x ==5)

{

 document.write(x);

}

else

{

  document.write(“Not Five”);

}

In this case X is not equal to five, so the code in the “Else” statement is activated. Printing “Not Five” to the screen.

 

var x = 9;

if( x ==5)

{

 document.write(x);

}

else if(x==9)

{

  document.write(x);

}

else

{

 document.write(“Not five or nine.”);

}

In this case the second condition checked is true, so 9 will be printed on screen. If both conditions were false, then the code of the “else” would have printed.

 

As I mentioned in the beginning of this post, these statements are essential for computer programming and are used greatly in loop structures to direct the program in what to do and when.

 

 

 

 

 





Comments

12/23/2009 6:53:48 PM #

hk_webdesign

Thank you for sharing

hk_webdesign People's Republic of China |

2/15/2010 10:25:01 PM #

payday loans

All who have accomplished great things have had a great aim, have fixed their gaze on a goal which was high, one which sometimes seemed impossible.

payday loans United States |

3/23/2010 10:13:46 PM #

loan until payday

Super-Duper site! I am loving it!! Will come back again - taking you feeds also, Thanks.

loan until payday United States |

3/27/2010 4:40:22 AM #

sameday cash advance

I wanted to say that it's nice to know that someone else also mentioned this as I had trouble finding the same info elsewhere. This was the first place that told me the answer. Thanks.

sameday cash advance United States |

3/29/2010 7:37:57 PM #

quick money loans

There is obviously a lot to know about this.  I think you made some good points in Features also.

quick money loans United States |

3/30/2010 5:31:20 AM #

quick bad credit loans

Very interesting post - Might be old news, but it was news to me.

quick bad credit loans United States |

4/1/2010 4:07:56 PM #

stretchmark treatment

Hi there, I found your blog via Google while searching for first aid for a heart attack and your post looks very interesting for me.

stretchmark treatment United States |

4/28/2010 1:02:27 AM #

Rapidshare

I\'m happy I found this blog, I couldnt discover any info on this subject matter prior to. I also run a site and if you want to ever serious in a little bit of guest writing for me if possible feel free to let me know, i\'m always look for people to check out my site. Please stop by and leave a comment sometime!

Rapidshare United States |

4/29/2010 8:35:22 PM #

low interest rate personal loans

Wow! Thank you! I always wanted to write in my site something like that.

low interest rate personal loans United States |

5/25/2010 9:49:22 AM #

no teletrack payday loans

Super-Duper site! I am loving it!! Will come back again - taking you feeds also, Thanks.

no teletrack payday loans United States |

5/30/2010 12:25:29 AM #

free game online

Hi webmaster, thank you very much for providing this excellent post! I found it outstanding. Cheers,  !!

free game online United States |

5/31/2010 1:27:59 PM #

download free card games

Extraordinary article..

download free card games United States |

6/17/2010 10:35:32 AM #

Custom jerseys


Extraordinary article..

Custom jerseys People's Republic of China |

7/4/2010 9:58:55 PM #

advertising surrey

Come on guys, let's keep it clean. This is a good blog. Good info mate.

advertising surrey United States |

7/5/2010 5:24:28 AM #

power weight loss

"A great attitude does much more than turn on the lights in our worlds; it seems to magically connect us to all sorts of serendipitous opportunities that were somehow absent before the change." Earl Nightingale

power weight loss United States |

7/8/2010 3:48:43 AM #

Borden, Britt

Thank you for another informative blog. Where else could one get that kind of info written in such a perfect way? I have a presentation that I am presently working on, and I have been looking for such information.

Borden, Britt United States |

7/8/2010 2:38:21 PM #

verifone manual

Hey admin, I like MS Blog Engine but why did you chose it?  I mean it's so cool with the random avatars and draws people in, but what speficially made you want to use it?

verifone manual United States |

7/9/2010 12:06:03 AM #

Top Interview questions

Do you like running Blogengine?  If I might --perhaps you should consider adding a few images.  I dont mean to disrespect what you've done here; its very good stuff, for sure.  But, I think would respond to it more positively if you could add something tangible to your posts.  Keep it up, but put a little more into it next time.

Top Interview questions United States |

7/9/2010 2:15:46 AM #

Software Review

Have just subscribed to the feed, thx a bunch for all of the effort you put into <A href="identi.ca/freesoftwarereview">software review</A>

Software Review United States |

7/9/2010 3:05:58 PM #

Alfred Bush

Hi, maybe you could help me? I saw u are utilizing Blog Engine on your website. I lately made a decision to launch a blog for myself and i'm presently making use of a wordpress blog. I read about blog engine and i was wondering if you could tell me exactly where i could get the very great instruction or videos on how to use it correctly? Thanks for that assistance.

Alfred Bush United States |

7/25/2010 9:24:14 PM #

Webhostingpad Coupon

Ah, I discover the fact has unlimited debatable points. I don't need to argue with you right here, however I have my own opinions as well. Anyway, you probably did a great job in writing the put up, and wish to praise you for the laborious work. Keep up with the good job!

Webhostingpad Coupon United States |

7/28/2010 3:24:24 PM #

FatCow Review

Cheers for this blog post, It's great to see another BlogEngine user. Most users these days tend to use Wordpress, but in my opinion, BlogEngine.NET is the best system to use.

FatCow Review United States |

7/28/2010 6:39:52 PM #

Beau Basse

programming programming programming Hello, I was researching the internet  & I discovered your web site. Keep up the superb job.

Beau Basse Azerbaijan |

8/1/2010 5:43:37 PM #

Kira Fattig

Hi, I�m fairly impressed by your blogging talent about programming . Please make contact with me if a part-time blog career looks like some thing you be considering

Kira Fattig Lebanon |

8/3/2010 1:46:17 PM #

football shirts

Why didn’t I find this post earlier? Keep up the good work!

football shirts United Kingdom |

8/3/2010 5:24:57 PM #

Glennis Dutile

Would you say yes guest posts? I would like to write pair articles here.

Glennis Dutile Jordan |

8/3/2010 5:26:32 PM #

Chester Badder

Hello webmaster, your web web page's design is superb and i like it. Your posts are wonderful. Please keep up the good work. Sincerely!!!

Chester Badder Belarus |

8/8/2010 1:52:25 PM #

Andrew Pelt

Hello, I was reading-through this article from the phone and this seems to be kinda strange. Believed you’d want to know. This is a great post even so, just didn't mess that up.

Andrew Pelt United States |

8/8/2010 4:15:52 PM #

online investing for beginners

Hi amazing site, I discovered your web site as I was doing some investigation on some methods to improve my site. I was just now enquiring which spam software system you use for comments as I get a good deal on my blog.

online investing for beginners United States |

8/8/2010 5:36:55 PM #

Loren Schrum

Hey, i Think your blog is good!! I found it on yahoo I think i will come back one day

Loren Schrum United States |

8/9/2010 12:35:49 PM #

Compauter reviews

I also have a computer blog, but I took it from somewhere else, not like the contents of your blog is really good.

Compauter reviews United States |

8/9/2010 5:27:37 PM #

Laura

I posted a response here that was courteous and professional. My opinion differed from yours but that doesn't seem a reason to censor me. Why was it removed??

Laura United States |

8/9/2010 7:41:46 PM #

Laine Linan

I'm diggin' this blog. Alot of interesting info.

Laine Linan United States |

8/10/2010 6:22:08 PM #

Jordan Shoes

I'm a blog enthusiast and with so many blogs out there now, not very many stand out like yours does. This blog caught my attention and I thought that I would post to let you know.

Jordan Shoes United States |

8/10/2010 8:32:03 PM #

abercrombie

Do not share fully the post, but the argument is well well-known. Congratulations to the writer of the website

abercrombie United States |

8/11/2010 9:26:58 AM #

North American

Hello
I agree with your entry Web Design Blog | A look at If, Else logic.. I will make sure to be reading your website more.
See you

North American United States |

8/12/2010 8:31:09 AM #

500658-B21

Really enjoyed the blog, keep up the good work

500658-B21 United States |

8/12/2010 11:17:30 AM #

magic slim

This is such a great resource that you are providing and you give it away for free. I enjoy seeing websites that understand the value of providing a prime resource for free. I truly loved reading your post. Thanks!

magic slim United States |

8/14/2010 1:49:27 PM #

Webhostingpad Coupons

Good day, I enjoyed reading your post. Thanks for the nice info. Was hoping that we can prolong our friendship by way of a mutual hyperlink change? Let me know, and nice to have found you here!

Webhostingpad Coupons United States |

8/16/2010 3:22:59 AM #

Hot Stocks

Hey how are you. I found your blog through Google and I just wanted to say that I think your writing is simply stunning! Thanks again for providing this content for free.

Regards

Jannie Waze!

Hot Stocks United States |

8/16/2010 8:57:40 PM #

reverse cell phone lookup

Hey how are you. I found your blog through Google and I just wanted to say that I think your writing is simply stunning! Thanks again for providing this content for free.

Regards

Kaze Marley!

reverse cell phone lookup United States |

8/17/2010 2:00:39 PM #

Panda Internet Security Coupon

Very informative post, love the way you write and I feel that the knowledge helps in a way. I don't usually say this, but I think this is a great job done. For those who like to exchange links, I might be more than happy to supply a hyperlink back to your site. Hope to listen to from you soon. Cheers

Panda Internet Security Coupon United States |

8/17/2010 6:50:53 PM #

Contour Abs

Have you ever considered adding more videos to your blog posts to keep the readers more entertained? I mean I just read through the entire article of yours and it was quite good but since I'm more of a visual learner,I found that to be more helpful. Just my my idea, Good luck  

Regards

Craig Maze!

Contour Abs United States |

8/18/2010 2:06:19 AM #

Annabell Uhri

I like this blog. The only thing that I do not like is that I did not find the blog earlier.

Annabell Uhri United States |

8/19/2010 7:00:38 AM #

affiliate networks

I was introduced to the thought of Network Marketing about in 2009. Used for, I came online and Googled the following phrase "How to succeed in Network Marketing". A few months and continuous education later, I learnt how others made fortunes on-line using Internet Formulas and Network Marketing programs. These were people who were the least likely to have made so much money because they were non tech savvy folks. Some were wrestlers by profession, others were school teachers.

affiliate networks United States |

8/19/2010 11:13:51 PM #

antivirus reviews

Why didn?t I find this post earlier? Keep up the good work!  

Regards

Jhaze Phil!

antivirus reviews United States |

8/20/2010 1:32:47 AM #

mesothelioma lawyers

I am writing a report on this subject and your post is very helpful and informative. Thank you  

Regards

Jing Philips!

mesothelioma lawyers United States |

8/20/2010 5:48:57 PM #

suits

Hi. I wanted to drop you a quick note to express my thanks. I've been following your blog for a month or so and have picked up a ton of good information as well as enjoyed the way you've structured your site. I am attempting to run my own blog but I think its too general and I want to focus more on smaller topics. Being all things to all people is not all that its cracked up to be.

Regards

Jing Philips!

suits United States |

8/21/2010 9:47:09 PM #

SomnaPure

Why didn?t I find this post earlier? Keep up the good work!  

Regards

Eric Kings!

SomnaPure United States |

8/22/2010 10:13:32 AM #

Doradca kredytowy

well I guess you learn something new everyday. Got something outta this that I realize before. Thanks…

Doradca kredytowy United States |

8/23/2010 12:51:41 AM #

otein Powder

Hey how are you. I found your blog through Google and I just wanted to say that I think your writing is simply stunning! Thanks again for providing this content for free.

Regards

James Willmort!

otein Powder United States |

8/23/2010 1:32:24 PM #

Whey Protein

Hey, I just forwarded this to some friends, loving it! Smile

Regards

James Willmort!

Whey Protein United States |

8/24/2010 2:20:04 AM #

K9 Advantix Blue

Hi I attempted to sign up to your RSS and the link seems to be broken. How can i get around this?

Thank you!

K9 Advantix Blue United States |

8/24/2010 4:04:56 PM #

dress up games

Aw, this was a really quality post. In theory I'd like to write like this too - taking time and real effort to make a good article... but what can I say... I procrastinate alot and never seem to get something done.  

Thank you!

dress up games United States |

Comments are closed


About the author

 The creators of the Web Design Blog have been creating web designs for over 12 years

Page List