Print Design Templates Take a look at these creative Graphic Design templates for brochures, flyers, newsletters, stationery, postcards, ads, menus and posters for a variety of businesses.
Invoicing 4 Freelancers A complete, secure, online billing application that maintains hourly service billing, flat fee billing and recurring charges. Integration with Authorize.Net and other leading payment gateways provides hands-free recurring billing with a sophisticated CRM system.
Free Design Magazines Browse through our extensive list of free Graphic Design, Web Design, Business, Computer, and Computer Graphics magazines, white papers, downloads and podcasts to find the titles that best match your skills and interests; topics include management, marketing, operations, sales, and technology. Simply complete the application form and submit it. All are absolutely free to freelance professionals who qualify.
Suggested Links Photoshop Tutorials
Logo Designer's Logos
Web Design Tools List
Layouts & Templates Directory
Web Design & Graphic Design Blog
Photoshop, Flash, 3D Studio Max Tutorials
Web Designers & Developers
Crafts for Kids
Photoshop Tutorial Man
Tutorial Guide -- Free Webmaster Tutorials
Design Contests
How to Draw
Work From Home Job Search
OTHER SITES WE OWN
AllFreelance
Graphic Design Resources Directory
Graphics Tutorials Directory
Social Networking Articles
Design Sites Up
All Freelance Work & Portfolios
Graphic Design Community
Education & Learning Directory
![]() |
home > Web Design Tutorials > Programming Tutorials > Javascripting Articles > Javascript Conditional Statements Coding Tutorials
Conditional Statements
A conditional statement is used to execute a portion of code, based on the outcome of whether a condition is met. We perform these types of operations all the time in our everyday lives.
Object Properties and Flow Controls
This article, the second in our series of JavaScript Tutorials, covers variables within objects, the use of If, Else and Switch, plus loop statements including For, In, While, Break and Continue.
Statements
Statements define the flow of a script, known as "program flow." A statement, like a fully grammatical English sentence, is made up of smaller expressions which, altogether, evaluate into a cogent meaning. In JavaScript, statements are organized as either
JavaScript If...Else Statements
Conditional statements in JavaScript are used to perform different actions based on different conditions.
If statement Example
How to write an if statement.
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
||
If...else statement Example
How to write an if...else statement.
If..elseif...else statement Example
How to write an if..else if...else statement.
JavaScript Switch Statement
Conditional statements in JavaScript are used to perform different actions based on different conditions.
Switch statement Example
How to write a switch statement.
if Statement, Boolean, Functions and Variable Scope
This lesson introduces you to two essential constructs of the JavaScript language, the if statement and the function.
JavaScript Programming, Flow of Control
JavaScript supports several different kinds of statements designed to alter or control the logical flow of control in the script…
IF/ELSE Statements
This second If example includes a random number, two functions, and introduces If/Else. If/Else allows the program to decide what to do both when the condition is true and when the condition is false, thus increasing your control of your program.
IF AND ELSE
Sometimes javascript requires the ability to make distinctions between different possibilities…
Controlling Program Flow
In this tutorial you'll learn how to write code to make decisions (e.g. "if the user has selected this checkbox, display this message"), and perform the same action many times (called "looping")…
Conditional Operators
Conditional statements allow you to control the flow of execution of a script or one of its sections. To do this, you use some keywords and associate them with expressions to check. Depending on the outcome of the checking process and other comparison ope
Conditional Statements
A script is usually executed in a top-down approach. Instead of letting the browser proceed as you wish, you can set a condition that would control the sequence of processing. If the condition you set if true, then you can perform a desired operation. Th
if-then Branching
What "if-then" statements do is allow your program to behave very differently depending on what a user inputs…
Example of a Simple if-then Statement
If you typed yes in the prompt box, you should have received a warm greeting before seeing the rest of the page. If you typed something else, you shouldn't have received any greeting at all.
The if/else Statement
Another type of conditional statement is called an if/else statement. It adds another dimension to the if statement. This statement allows for more complex decisions to be made within the script.
Conditional Expressions
There is another method for writing conditional statements, so long as it is a true or false statement. This method uses the conditional operator ( ?: ).
The Switch Statement
The switch statement provides the user with several options and returns a result based upon the user's selection.
JavaScript Conditional
Making decisions is an integral part of any programming language, including JavaScript. They allow your programs to choose from alternative actions to be taken based on a condition.
Nesting If / Else Statements
Using nested if/else statements, this example has defined the value of a new variable that prints…
JavaScript IF Statement
The beauty of programs lies in the fact that they are able to take decisions on the basis of information you provide. In all the programming languages I've come across, the If statement is extensively used for this purpose…
JavaScript IF-ELSE Statement
Each condition has two paths from which we choose one. For example, "If it's raining, I'll stay at home else I'll go out for a stroll."
JavaScript: Else If
We've already learnt that conditions can take one of the possible two paths. That is, when the condition is 'true' the if statement block is executed while the statement block in else is executed when the condition is 'false'. However, as in life, things
Control structures
In this tutorial you'll learn how to write code to make decisions…
Controlling program flow
The behavior of your script depends on user actions, events in the program, results of the computation and many other things. How do you tell your script to change the program flow in response to various events? The three main ways are…
switch case construct
The switch case construct is used in situations where using multiple if statements would be cumbersome. The switch case construct is used to check a variable against multiple values.
If ...Else Construct
The if construct is used for conditional processing…
Conditional operators
In this tutorial you will see the more compact way of using conditional operators like if ... else in JavaScript. Really, the more you live the more you learn…
Conditionals
Some statements in JavaScript are known as conditional statements. These statements have control structures that delimit them which determine whether or not the delimited code is executed, based on some condition…
The IF Statement
In this tutorial we are going to look at a couple more types of operators. These operators are commonly used in if statements.
The CASE Statement
The if statement is one of the ways that you can select which code to process based on values contained within particular variables or comparisons between these values.
STATEMENT: switch
The switch statement tests an expression against a number of case options and executes the statements associated with the first one to match…
STATEMENT: while
The while statement creates a loop consisting of a block of statements that is executed if the expression evaluated is true…
JavaScript Conditional Statements
Conditional statements can be used to perform certain tasks depended on the condition. In the real like, you are using these statements nearly each day and many times…
RECENT ARTICLES from Graphic Design BloG
[CaRP] Can't open cache file.
Business Cards: Ideas and Inspiration, Part II
Today we continue looking at business cards that stand out, and here’s hoping you get some inspiration and ideas! After all, you only get one first impression, so your business card should be something that showcases the best of your design abilities. On Wednesday we looked at the use of interesting shapes, 3D business cards, [...]
![]() |
![]() |
|
![]() |
![]() |
|
[CaRP] Can't open cache file.
Making the Move from Freelance Work to Full-Time Employment
If you are like me, after graduating from a graphic design school, your goal was to make it as a freelance web designer. The lure of flexible hours, working from home and the freedom to manage your own time was too much to resist. At some point, I decided it may be ?easier? to work [...]
Tips for Asking for a Raise
At some point in our careers, there is a time when we open our paychecks and breathe a sigh of disappointment. After years of studying at a graphic design school and countless hours spent devoted to learning from colleagues and researching new design techniques, the numbers on our pay stub just don?t seem to measure [...]
Stock vs. Original Digital Photography
A picture is worth a thousand words. Graphic design schools teach us that photos on web sites have the potential to capture our attention, motivate us to read more or even propel us to navigate to another web site entirely. They inflict emotion and can establish a connection between site visitors and the goods or [...]
3 Tips to Manage Content Updates
While walking through the pharmacy I passed the aisle filled with red heart-shaped boxes filled with chocolates and remembered Valentine?s Day is quickly approaching. Even though I was surrounded by so many representations of love, it reminded me of one thing that I actually despise ? web content updates! Graphic design schools teach many, many [...]
Should You Drop the Drop-Down Menus?
I was recently on a home improvement web site searching for ideas for renovating my bathroom. After a few minutes on the site I realized that I was not going to find what I was looking for ? it certainly could have been there, but I just could not find it. Menu after menu had me [...]
Sharpen Your Skills and Gain an Edge at 2011 Web Design Conferences
Graphic design schools prepare us well for our immediate future, but it takes effort to stay on top of the ever-changing field of web design. Following are a few of the upcoming conferences and trade shows meant to help you stay a step ahead of the competition.
Interaction Eleven In its fourth year, Interaction Eleven is [...]
All Web Design Resources is a Directory & Blog Full of Tools for Web Site Designers
All Web Design Resources Portal is a Web Site Design education directory with resources & articles for Graphic Designers, Web Developers, & Web Designers including a Web Design forum, blog, graphics software tips, web development resources, web programming tools, web design jobs, advice for new web designers about web design schools and education as
well as tips for freelance web design business owners, and much more.