Hi guys! I made an RPS Game to test my abilities on JS. What do you think? How I can improve the quality of the code?
Thanks!!!
Thanks!!!
Well, for one there is a lot of code repetition.
You can for example simplify your code by putting all the possible outcomes for when a user wins in one IF statement, make an else if for when it’s a draw and put everything else in an Else statement (so in this case, the computer will win).
Did it!!! Thanks @SebastiaanSimons. I suppose that maybe I can try to use ES6 to simplify some functions?
The design is really creative! Great job on that.
I think something that could be implemented is a delay between the user’s choice and the CPU’s.
For example, after the user makes a decision, you could make the text show “you picked (object)” then after a short delay, the text would show 'CPU picked (object)", followed by ‘you win’ or ‘you lose’.
A couple typos within your code. ‘comparissons,’ should be spelled ‘comparisons.’ and ‘choosen’ should be ‘chosen’.
The volume of the effects could also be adjusted. The ‘victory’ sound that plays after beating the CPU 3 times is much louder than the other sounds. Also, you can make it so the sounds cuts off if the user hits ‘play again’. Right now if you win 3 times, the ‘victory’ song plays, but if you hit ‘play again’ the song keeps playng until it’s done. It should stop after the user clicks ‘play again’.