-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
  • 11,309
  • 4
  • 26
  • 41

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
  • 40,575
  • 10
  • 44
  • 74
Chandan Kumar
  • 741
  • 6
  • 21