+ 2
[ASSIGNMENT] What we should write here to make condition succed ??*without changing the code*
if(x == 5 && x == 10 && x == 15) {console.log("true");}
11 Answers
+ 4
Very neat challenge.
Solved by overriding toString
https://code.sololearn.com/WCMQyo5njf9D/?ref=app
+ 15
So, what is the right answer?
+ 3
var x=5;
if(x == 5 || x == 10 || x == 15)
{console.log("true");}
+ 1
What are you trying to accomplish?
If you're wanting it to check if 'x' is either 5, ,10, or 15, then the answer you received from Muhammad is correct.
+ 1
no I, want you to solve it with and gate "&&" not "||". Just write some code before the condition to make the program output true
+ 1
If you want an alternative to the IF check, you can use a SWITCH instead since your values are particular.
Example:
var x = 5;
switch(x){
case 5:
console.log("It's 5! True.");
break;
case 10:
console.log("It's 10! True.");
break;
case 15:
console.log("It's 15! True.");
break;
default:
console.log("False!");
break;
}
+ 1
I see. You should specify that more concisely in your question or description then. When you read it, it sounds like you have a question about how to make your code work properly.
+ 1
ok I will edit it nowđđ
+ 1
đ No problem. I'm curious to see the answer for it.
+ 1
đđđ
0
wrong answer