Here's the const that contains the objects array:
const SELECTIONS = [{
name: 'fire',
emoji: '',
beats: 'air',
beats: 'lizard'
},
{
name: 'water',
emoji: '',
beats: 'spock',
beats: 'fire'
},
{
name: 'air',
emoji: '',
beats: 'water',
beats: 'lizard',
},
{
name: 'lizard',
emoji: '',
beats: 'air',
beats: 'spock',
},
{
name: 'spock',
emoji: '♂️',
beats: 'fire',
beats: 'water',
},
];
Here's the function that returns the winner by comparing the property/key values of player and computer selection
function isWinner(selection, opponentSelection) {
return selection.beats === opponentSelection.name
}
I added a pair to the object since I have taken a paper, rock and Scissors game and converted it to a paper, rock , Scissors, spock and lizard game.
Or at least I've tried...
I want the function to compare both the 'beats' . I have tried to rewrite the object and the function with no success.
Does anyone have a clue?