+ 2

Can you solve this problem?

Write a javascript that makes true the following condition: if (a==1 && a==2 && a==3) { ... }

26th Mar 2018, 8:22 PM
Sara
Sara - avatar
2 Réponses
+ 2
const a = { num: 0, valueOf: function() { return this.num += 1 } }; const equality = (a==1 && a==2 && a==3); console.log(equality);
26th Mar 2018, 8:40 PM
Abdurrahman Abulgasim
Abdurrahman Abulgasim - avatar
+ 2
const a = { i: 1, toString: function () { return a.i++; } } if(a == 1 && a == 2 && a == 3) { console.log('Hello World!'); }
26th Mar 2018, 8:42 PM
Jeff Block
Jeff Block - avatar