Skip to content
Advertisement

how to compare two strings in multiple cases?

I can input 2 strings, a or b they could be either rock,scissors, lizard,paper or spock.

their relationship is:

JavaScript

how to write this program?

Thanks

Advertisement

Answer

I would do it by making a win/loss matrix. The matrix contains a 1 where the row beats the column:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement