+ 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");}

4th Apr 2018, 1:18 PM
Yehia Tarek
Yehia Tarek - avatar
11 Answers
+ 4
Very neat challenge. Solved by overriding toString https://code.sololearn.com/WCMQyo5njf9D/?ref=app
6th Apr 2018, 5:35 AM
Rrestoring faith
Rrestoring faith - avatar
+ 15
So, what is the right answer?
4th Apr 2018, 2:59 PM
Igor Makarsky
Igor Makarsky - avatar
+ 3
var x=5; if(x == 5 || x == 10 || x == 15) {console.log("true");}
4th Apr 2018, 1:23 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 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.
4th Apr 2018, 1:37 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 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
4th Apr 2018, 1:40 PM
Yehia Tarek
Yehia Tarek - avatar
+ 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; }
4th Apr 2018, 1:40 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 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.
4th Apr 2018, 1:41 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 1
ok I will edit it now👍👍
4th Apr 2018, 1:43 PM
Yehia Tarek
Yehia Tarek - avatar
+ 1
👍 No problem. I'm curious to see the answer for it.
4th Apr 2018, 1:44 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 1
👍👍👍
6th Apr 2018, 6:29 AM
Yehia Tarek
Yehia Tarek - avatar
0
wrong answer
4th Apr 2018, 1:29 PM
Yehia Tarek
Yehia Tarek - avatar