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

Difference between durable and non-durable subscriptions, Point-To-Point (P...

Point-To-Point (PTP). This model permits exchanging messages via queues formed for some purposes. A client can send and receive messages from one or various queues. PTP model is ea

Opps Concepts, 300 words on oops and 1 program for each concepts

300 words on oops and 1 program for each concepts

Write a cgi program, Write a CGI program in R, accessible through the class...

Write a CGI program in R, accessible through the class web server, that performs an analysis or creates a graph. You can provide a separate HTML page that displays the initial form

Write a recursive function, 1) Write a function that uses recursion that co...

1) Write a function that uses recursion that converts a decimal number to octal (base 8). The function should accept a single integer and return a String containing the base 8 equi

Difference between while statement and a do while statement, What is the di...

What is the difference between a while statement and a do while statement? A while statement checks at the starting of a loop to see whether the next loop iteration should occu

Develop android geolocation service app, Project Description: Develop an...

Project Description: Develop an android service app that will run on the background. The app has to get the users location (longitude and latitude) every 5 minutes or when th

Develop a client-server student record application, Develop a Client/Server...

Develop a Client/Server (MySQL) student record application Project Description: I need a client/server application with a MySQL backend database. The prototype could interfac

What is role of action class, An Action Class performs a role of an adapter...

An Action Class performs a role of an adapter among the contents of an incoming HTTP request and the corresponding business logic that should be implemented to process this request

I need 3d globe application, I need 3D Globe (Android) application Proje...

I need 3D Globe (Android) application Project Description: Seeking a talented android programmer to prepare a simple app for Android tablet display which can feature a 3D glo

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