export const allTheSame = (x, y, z) => { if ( x || y || z === true) { return true; } else if (x && y || z === false) { return true; } else { return false; } }
the 5 details i'm getting are all correct except the 4th of them. Pls Help
miidiin try this works like a charm 😆 export const allTheSame = (x, y, z) => { if (x == y && y==z) { return true; } else{ return false; }; } miidiin
Wow! I didn't know we could do this ( x || y || z === true) or this (x && y || z === false)! 😅 I though it could only be done like this ( x === true || y === true || z === true) and (x === false && y === false || z === false)!
( x || y || z === true)
(x && y || z === false)
( x === true || y === true || z === true)
(x === false && y === false || z === false)
@miidiin in your code line 2 you are saying that if x or y or z is true, then return true...BUT what is asked is, if ALL of them are true or ALL of them are false! So, they must be all equal, all false or all true. If are not all equal then it should return false. Hope I helped a little.
thanks man ... but i'm still not getting past it
alxjspalma
I can't tell more, but you can see different of my code and yours.
export const allTheSame = (x, y, z) => { if ((x == true && y == true && z == true) || (x == false && y == false && z == false)) { return true; } else { return false; }; }
dierdragoon
thanks a bunch man
zacc
This is the cleanest and most concise
This solution is working fine export const allTheSame = (x, y, z) => { if (x === y && x === z) { return true; } else { return false; } }
export const allTheSame = (x, y, z) => { if (x === y && x === z) { return true; } else { return false; } }
Here my 2 cents (it works, too): export const allTheSame = (x, y, z) => { if (x===y && x===z && y===z) return true; else return false; } Now, my question is, what's the difference between === and ==?
export const allTheSame = (x, y, z) => { if (x===y && x===z && y===z) return true; else return false; }
alorenz https://learn.coderslang.com/0159-the-difference-between-javascript-equality-operators-and/
this works fine 🙂 export const allTheSame = (x, y, z) => { return (x && y && z) || (!x && !y && !z); };
export const allTheSame = (x, y, z) => { return (x && y && z) || (!x && !y && !z); };