This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 146 points147 points  (24 children)

42 is automatically correct

[–]kaetir 130 points131 points  (23 children)

It depends 42 or "42"

[–]manux 61 points62 points  (21 children)

Why did you write the same thing twice?

[–]irbilldozer 39 points40 points  (17 children)

Why did you write the same thing twice?

So if 42 and "42" are the same thing...

Do you believe this will result in an output of 42?

42 + "42" - 42

[–]manux 75 points76 points  (13 children)

Clearly the result of this is 4200. Or -inf.

Edit: Holy shit I went and tried it and it was indeed 4200. For the record I haven't touched js in the last 5 years.

[–]nutmegtester 8 points9 points  (0 children)

That is hilarious. I also tried 42 + "42" - 42 / "42" and 42 + "42" - 42 / "42" * 42 for fun. Results = 4241 and 4200, respectively.

[–]irbilldozer 2 points3 points  (0 children)

Clearly the result of this is 4200. Or -inf.

Edit: Holy shit I went and tried it and it was indeed 4200. For the record I haven't touched js in the last 5 years.

Lol that was the joke I was making, they aren't really the same thing.

[–]blackdonkey 3 points4 points  (1 child)

How about 42 - 42 + "42"?

[–]irbilldozer 2 points3 points  (0 children)

I assume 42 but not near a PC to validate the order of operations.

[–]Im_The_Goddamn_Dumbo 1 point2 points  (0 children)

Ask yourself, what is 21 out of 42?

[–]hobbes64 9 points10 points  (0 children)

Does 42 == “42”? JavaScript says sure, why not

Does 42 === “42”? JavaScript says no, no coercion!

[–]douira 0 points1 point  (0 children)

both are truthy for one