Which is better | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
7 Answers
+ 3
Both are excellent, however, picky me finds redundant statements in both codes (😝), such as: Thomas's: "if ( (!isValid( user )) || (!isValid( opponent )) ) { return false; }" He's already checked if the users input is valid, and computer can't have invalid input. So this if statement does nothing. Yours: You have plentiful if statements that take into account all possible cases. However, there's no need to check EVERYTHING, you can cut short. For example, If you take into account all wins and ties then there's no need to check losses. You can just assume he lost. (This is done with else if/ else statements, Which I suggest you use more often when necessary). You also have more if statements than needed. Anyhow, Great Job, it works great!
17th Jun 2017, 8:27 PM
Rrestoring faith
Rrestoring faith - avatar
+ 3
Practice surely makes better! It's a great code anyway. I suggest you practice OOP (object oriented programming), it will surely enhance your skills.
17th Jun 2017, 8:32 PM
Rrestoring faith
Rrestoring faith - avatar
+ 2
love them both XD
17th Jun 2017, 8:10 PM
Henry Arch
Henry Arch - avatar
+ 2
meh i dont feel like a pro coder the most thing that is advanced is creating methods using equal sign if statements (i cant proceed more becuase i cant find a way
17th Jun 2017, 8:30 PM
Ishaq Za'rour
+ 1
no the better
17th Jun 2017, 8:13 PM
Ishaq Za'rour
+ 1
as a code not the output
17th Jun 2017, 8:13 PM
Ishaq Za'rour
+ 1
the input
17th Jun 2017, 8:13 PM
Ishaq Za'rour