Conditional Statments

  1. Conditional statments are used to perform different actions based on different conditions.
  2. Very often when we write code, we wanted to perform different actions for different decisions.
  3. We can use conditonal statement in our code to do this.

var firstName = 'Roopak';
var civilStatus = 'single';

if(civilStatus === 'married') {
console.log(firstName + ' is married');
} else {
console.log(firstName + ' will hopefully marry soon
:)');
}

var isMarried = true;
if (isMarried) {
console.log(firstName + ' is married!');
} else {
console.log(firstName + ' will hopefully marry soon
:)');
}


click 'Check' to see the answer