V.Vidhya Logo

V.Vidhya

Logical Operators


Q1.

let a = 5;
let b = 10;

let result = (a > 3) && (b < 5);

What will be the value of result?

You have to predict the output yourself without running/executing the code.

  1. true
  2. false
  3. 0
  4. No output due to an error

Q2.

A “good string” is a string that starts with the letter ‘a’ & has a length > 3. Write a program to find if a string is good or not.

// examples

And - bad string
Almond - good string
Potato - bad string

Q3.

Predict the output of the following code:

You have to predict the output yourself without running/executing the code.

let num = 12;

if ((num % 3 == 0) && ((num + 1 == 15) || (num - 1 == 11))) {
    console.log("safe");
}
else {
    console.log("unsafe");
}

Prev Post
if-else (Conditional Statements)
Next Post
switch (Conditional Statements)