Rock, Paper, Scissors x99: function setPlayerMoves "AssertionError: expected undefined to equal 'rock'"

I’ve tried to fix this issue for a few hours now but cannot find a way to implement it. The testing suite says that it fails to set both player’s moves with valid inputs, elaborating that “AssertionError: expected undefined to equal ‘rock’”.

I am pretty sure it is caused by the global variable not being returned after I change it, so it defaults to undefined, but I cannot find a way to implement a way to return it. I’ve tried multiple forms of arrays to return multiple variables. I have deleted the return portion I had because my other attempts weren’t working. At this point, I don’t even know if what I think is the problem really is the problem, so I’m looking for an outside and more experienced perspective on how to fix this.

let playerOneMoveOneValue = undefined;
let playerOneMoveTwoValue = undefined;
let playerOneMoveThreeValue = undefined;
let playerOneMoveOneType = undefined;
let playerOneMoveTwoType = undefined;
let playerOneMoveThreeType = undefined;

let playerTwoMoveOneValue = undefined;
let playerTwoMoveTwoValue = undefined;
let playerTwoMoveThreeValue = undefined;
let playerTwoMoveOneType = undefined;
let playerTwoMoveTwoType = undefined;
let playerTwoMoveThreeType = undefined;

function setPlayerMoves(player, moveOneType, moveOneValue, moveTwoType, moveTwoValue, moveThreeType, moveThreeValue) {
    if ((player === 'player one' || 'player two') && (['rock', 'paper', 'scissors'].includes(moveOneType)) && (['rock', 'paper', 'scissors'].includes(moveTwoType)) && (['rock', 'paper', 'scissors'].includes(moveThreeType)) && (moveOneValue <= 99 && (moveTwoValue + moveThreeValue) - 99) && (moveTwoValue <= 99 && (moveOneValue + moveThreeValue) - 99) && (moveThreeValue <= 99 && (moveTwoValue + moveOneValue) - 99)) {
        if (player === 'player one') {
            playerOneMoveOneValue = moveOneValue;
            playerOneMoveTwoValue = moveTwoValue;
            playerOneMoveThreeValue = moveThreeValue;
            playerOneMoveOneType = moveOneType;
            playerOneMoveTwoType = moveTwoType;
            playerOneMoveThreeType = moveThreeType;
        } else if (player === 'player two') {
            playerTwoMoveOneValue = moveOneValue;
            playerTwoMoveTwoValue = moveTwoValue;
            playerTwoMoveThreeValue = moveThreeValue;
            playerTwoMoveOneType = moveOneType;
            playerTwoMoveTwoType = moveTwoType;
            playerTwoMoveThreeType = moveThreeType;
        } else {
            return 'invalid'
    } else {
        return 'invalid'


1 Like

Hi, did you manage to solve this? In the test code I’m sure the strings are ‘Player One’ and ‘Player Two’ that it looks for, perhaps this is causing an issue.