Conditional statements in javascript, JAVA Programming

Assignment Help:

Very frequently when you write code, you desire to perform distinct actions for different decisions. You can employ conditional statements in your code to do this.

In JavaScript we contain three conditional statements which are following:

  • if statement - employ this statement if you desire to execute a set of code when a condition is true
  • if...else statement - employ this statement if you desire to select one of two sets of code to execute
  • switch statement - employ this statement if you desire to choose one of many sets of code to execute

if( myVariable == 2 ) {

myVariable = 1;

} else {

myVariable = 0;

}

If the value of myVariable in code is 2 then the first condition appraise to true and the value of myVariable is set to 1. If it is anything apart 2 then the else part gets executed.

Now let us see an instance of a nested if statement in above code

if ( myVariable == 2 ) {

myVariable = 1;

} else {

If (myVariable == 5 ) {

myVariable = 3;

} else {

myVariable = 4;

}

}


Related Discussions:- Conditional statements in javascript

What is numeric promotion, What is numeric promotion? Numeric promotion...

What is numeric promotion? Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place.

How is method overriding different from method overloading, How is method o...

How is method overriding different from method overloading? Overriding involves the creation of two or more concepts with the same name and same signature in different classes

I need viral script for facebook likes, Project Description: I need a Sc...

Project Description: I need a Script developer who can make script for me. Need urgently. Skills required: Java, Facebook Marketing, Javascript, PHP, Script Install

Give an examples of java.lang.math methods, Give an Examples of java.lang.M...

Give an Examples of java.lang.Math Methods Here is an instance program in which exercises most of the routines in java.lang.Math. If your high school math is a little rusty, do

What is the difference between internet and intranet, What is the differenc...

What is the difference between Internet and Intranet ? Intranet and internet are 2 domains which are extremely a like but frequent segregated in order to manage security. Inter

Advantages offered by soa, Advantages offered by SOA Splits down the s...

Advantages offered by SOA Splits down the silos of data, functionalities, and applications into enterprise services. Adapts an application to changing business requirements

Program to calculates the number of unique shapes, 1. Write the code for th...

1. Write the code for the method that calculates the number of unique shapes for a binary search tree with n nodes. Use the formula  where b n is the number of possible sh

Saaa, Write a program to find the area under the curve y = f(x) between x =...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.

Describe overriding methods, Describe Overriding Methods ? Assume that...

Describe Overriding Methods ? Assume that one day you've just finished your Car class. It's been plugged into your traffic simulation that is chugging along merrily simulating

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd