Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
The problem is not with the section of code that you quoted, the problem is with your
areOpposite
function. You are summing the first letter of each direction to see if they are opposites, but this doesn't really work because two possible direction combinations sum to the same number. Manually check'N' + 'N'
and'W' + 'E'
, and you should see what I mean. In this case, anytime yourareOpposite
function is called forNORTH
andNORTH
, it will returntrue
, which is not what you want.