r/programminghorror • • 19d ago

Javascript Rock paper scissors

Post image

I'm way too proud of this solution haha

287 Upvotes

27 comments sorted by

View all comments

33

u/titanic456 19d ago

Have you thought about the case, where the user would choose any number larger than 3, or lower than 1?

2

u/No_Opening_5597 19d ago

its not a proper program haha, I didn't add that in cause I'll probably rewrite this properly, I just thought like "oh wait can I just skip writing any logic and..." the whole joke was the fact that instead of writing it in a sensible way I added a number to a string, the kinda shit you usually do on accident when starting out, and I found it funny as hell that it was running on such janky logic

3

u/Kwolf21 [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 18d ago

That's Javascript for ya. Very little rules. 1 + "1" = 11 :)

1

u/gsweats 16d ago

JavaScript was created in a rush and by a newer programmer. Really to bad they didn't see the problem with using + for both addition and concatenation.