JavaScript Tutorial

Define JavaScript

JS Arithmetic Exercise

JavaScript Comment

JavaScript Variable

JavaScript Operators

Conditional Statements

Logical Operators

JavaScript Slider

JS Login Form

JS Popup Boxes

JavaScript Loops

JavaScript Arrays

JS Mouse Events

JS Keyboard Events

Styling Elements

External JavaScript

JS Noscript Tag

JS String Functions

JS Math Functions

JS Random

JS Date Functions

theme-changer

JS Assignment

JS Question-Answer

Page Stats

Visitor: 774

JavaScript Conditional Statement - if

If condition is use to execute statements on the basis of condition.

Example 1: Input 2 numbers and find greater.

Example 2: Input number and find it is Odd or Even.

Example 3: Change Image on Image Click.

Exercise on if condition

Exercise 1: Input age and find age is greater than or equals to 18 or not?

Exercise 2: Input amount of shopping and calculate discount if amount is greater than 1000 than 15% discount is given otherwise 5%.

Exercise 3: Select Country to find its capital using select option.

Conditional Statement : switch

Switch statement is use to select one of many blocks of code to be executed.
Example 1: Input number and Display cooresponding day. Like (Monday=1, Tuesday=2, ...).