-1

Help, how can I make this to "Correct" true without change the condition. Just changing the Variable value. In JavaScript

         Let Variable;
\*
         If(Variable == 1 && Variable == 2 && Variable == 3)
             Console.log("Correct");
           else
           Console.log("Incorrect");

*\
Alexander Nied
  • 12,804
  • 4
  • 25
  • 45

1 Answers1

-1

Use this given below code, it's working as per your logic

let variable;
if(variable == 1 && variable == 2 && variable == 3) {
    console.log("Correct");
} else {
  console.log("Incorrect");
}

Note: given condition never correct because one variable only hold one value use or condition (||).

let variable;
if(variable == 1 || variable == 2 || variable == 3) {
    console.log("Correct");
} else {
  console.log("Incorrect");
}
Jack Bashford
  • 43,180
  • 11
  • 50
  • 79
Chandan Kumar
  • 799
  • 7
  • 23