This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rockPaperScissors = function (n) { | |
// Capture the n or give it a default value of 3 | |
n = n || 3; | |
// Store the possible moves | |
const moves = ['R', 'P', 'S']; | |
// Store the possible game outcomes | |
const possibilities = []; | |
// Iterate on the number of options by the power of number of rounds | |
for (let i = 0; i < moves.length ** n; i++) { | |
// Store the current game outcome of all rounds |