Wednesday, August 18, 2021

If.......Else Statement in Javascript Language

How we use if...else staement to take decision in Javascript like other programming language

let age = 18;
let isOldEnough = age >= 18;
if(isOldEnough) {
console.log('She Can Drive a Car') // This Block Check for True Condition
}else {
console.log('She Can not Drive a Car') // This run when above mention Condition is Wrong.
}

let age = 16;
if(age >= 18) {
console.log(`She Can Apply For Driving Licence.`);
}else {
let leftAge = 18 - age;
console.log(`She can apply for driving licence after ${leftAge} years. `); // Used in backtick instead of quote
}

0 comments

Post a Comment