Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
return (john || doe || max || paul || stella ? "" : "Not ") + "Okay";
But that is only playing code golf.
Normally, you want code to be readable instead of just being short. -
My only 2p is that it's a stupid interview question. I wouldn't want to work anywhere that relied on micro-optimisation knowledge and code golfing over code readability.
-
Root797675yreturn(john|doe|max|paul|stella)?'Okay':'Not Okay';
Agreed with golf vs readability, though. -
A == B == C == D doesn't mean that they're the same. It means that
A == B && C == D || A != B && C != D -
Root797675y@Lor-inc Depends on language. Is it that way for java? (I don't have access to a jvm and didn't care enough to remedy that.)
-
wiwe22106145yThis is the kind of questions that make me annoyed because it doesn't have anything to do with writing quality code.
Related Rants
Interview Question:
Are there other options to make this go any shorter?
if (john == doe == max == paul == stella == false)
return "Not Okay";
return "Okay";
I did...
return (!john && !doe && !max && !paul && !stella) ? "Not Okay" : "Okay";
That was the shortest i could come up with... Maybe there is something shorter, dunno.
question
java
interview question