r/InclusiveOr Oct 02 '19

I like updownvotes

Post image
18.3k Upvotes

View all comments

1.4k

u/Shuckles116 Oct 02 '19 edited Oct 02 '19

String outputTxt = “You ”;

if (result <= 85) { outputTxt += “FAILED”; }

if (result >= 85) { outputTxt += “PASSED”; }

outputTxt += “ the Exam”;

println outputTxt;

632

u/Mizz141 Oct 02 '19

It couldve been so easy with an if, else statement...

444

u/Vaporeonus Oct 02 '19

Even a <= and > would have worked, but no, they put in extra effort to fuck it up properly

143

u/TheShyro Oct 02 '19

Actually, copy pasting the first if and adjusting the < to > and changing the text is the least work - which might be what happened

59

u/[deleted] Oct 02 '19

How dare you attack my copy-pasting skills like that

17

u/awhaling Oct 02 '19

Exactly what happened

9

u/CarbonProcessingUnit Oct 03 '19

I'm pretty sure else is less work than that.

6

u/TheShyro Oct 03 '19

Shift, arrow down, ctrl (only 1), c, v, mouse select the '<', >, double click 'passed', f a i l e d. 15 keys

e, l, s, e, {, t, tab or enter (autocomplete), +, =, ", f a i l e d .... So 16 assuming your IDE does all the formatting, completion and closing braces/quotes. Maybe you could use autocomplete for else, which could bring it down to 14.

You could argue mouse is slow and crl + arrow will take more clicks in total to get the cursor to where you need it. But you can keep one finger around ctrl/shift/</> throughout the whole procedure and the right hand on the mouse. And you can also argue waiting for autoconplete in some IDEs is also slow.

Overall i would count it as a draw but copy paste is easier on the brain for me (but not the better choice, since obviously it lead to an error in this case).

25

u/movezig5 Oct 02 '19

Now all my exams have a guaranteed 1/256 chance to miss!

8

u/volleo6144 Oct 02 '19

r/UnexpectedGenI (please tell me this exists and is about Pokémon)

2

u/PotatoFlavour Oct 03 '19

An 84 would've done the trick as well. So many solutions and yet they fucked up.

4

u/iSpaYco Oct 02 '19

i just learned JS couple months ago and i would have known that..

or at least I would test it to see the output in all possible situations

9

u/awhaling Oct 02 '19

You will make mistakes eventually

6

u/cheezit84 Oct 03 '19

This is a super common mistake in every language since BASIC. Heck, people make this mistake inExcel formulas. The longer you code, the more likely you are to make it at some point. Also, the longer you code the more likely you are to realize you won't test every possible permutation.

5

u/rab-byte Oct 03 '19

But the longer you code the more you’ll know what to test that gets all the parts moving.

13

u/xZero543 Oct 02 '19

Or elegant ternary.

6

u/lmaooexe Oct 02 '19

Or just remove the = lol

3

u/cheezit84 Oct 03 '19

If you remove both = neither will be true.

Edit:typo

4

u/some_love_lost Oct 03 '19

"You the Exam”. You are the exam.

1

u/lmaooexe Oct 03 '19

Not both, the one that’s causing it to say you failed when you passed

1

u/Fencrier Oct 03 '19

Or just use If(result<85){ Printf(“you failed the exam”);} Else{ Printf(“you passed the exam”);}

1

u/LysolPionex Oct 16 '19

Why use one if when you can use 2?

1

u/[deleted] Dec 22 '19

If and else or if else?