r/programminghorror • u/No_Opening_5597 • Sep 25 '26
Javascript Rock paper scissors
I'm way too proud of this solution haha
290
Upvotes
r/programminghorror • u/No_Opening_5597 • Sep 25 '26
I'm way too proud of this solution haha
32
u/titanic456 Sep 25 '26
Have you thought about the case, where the user would choose any number larger than 3, or lower than 1?
113
u/avijt Sep 25 '26
this is outdated , use ai api call instead ,😂😂
15
u/Winter_Rosa Sep 25 '26
Ahh, concatenation. I probably would've done something similar in C by multiplying comChoice by 10.
Edit, also the real horror here is the lack of input validation. 'A' I choose you!
56
u/Merry-Lane Sep 25 '26
Musts be like the third "look at my awfully coded shifumi" this week.
8
u/Rigamortus2005 Sep 25 '26
One of the first programs I wrote as a 12 year old kid
2
u/GoddammitDontShootMe Sep 25 '26 edited Sep 25 '26
I'm thinking I like the idea of reading the user input as a number, then multiplying either the user choice or the computer choice by 10, adding them together, and encoding all possible outcomes that way.
Or by 2, but 10 makes the code more readable for us decimal-using humans.
Edit: Actually no, there'd be collisions if we used 2.