So I’m doing the seconcd RPS game, where its coded on my computer and it has power values added in to the moves.
So I created the code to the first function (setPlayerMoves()) and tested it, and my edge cases passed but the main functionality tests didnt! I compared my code with the solution to see what i did wrong and it’s identical! i’ve been going through it character by character and can’t find any discrepancies, but when i paste the solution code into my file, and run the test, it works fine so i have NO idea what i’m doing wrong! someone please help me. My code is pasted below!
function setPlayerMoves(player, moveOneType, moveOneValue, moveTwoType, moveTwoValue, moveThreeType, moveThreeValue) {
if(!moveOneType || !moveOneValue || !moveTwoType || !moveTwoValue || !moveThreeType || !moveThreeValue){
return; //if anything is not provided, do not proceed
}
if(!isValidMoveType(moveOneType)||!isValidMoveType(moveTwoType) || !isValidMoveType(moveThreeType)){
return; //if any of the types don’t match one of the three options, don’t proceed
}
if(!isValidMoveValue(moveOneValue) || !isValidMoveValue(moveTwoValue) || !isValidMoveValue(moveThreeValue)){
return; //if any of the three types don’t fall into the range, don’t proceed
}
if(moveOneValue + moveTwoValue + moveThreeValue > 99){
return; //if sum of values is more than maximum, don’t proceed
}
if (‘player’ === ‘Player One’) {
playerOneMoveOneType = moveOneType;
playerOneMoveOneValue = moveOneValue;
playerOneMoveTwoType = moveTwoType;
playerOneMoveTwoValue = moveTwoValue;
playerOneMoveThreeType = moveThreeType;
playerOneMoveThreeValue = moveThreeValue;
}else if ('player' === 'Player Two'){
playerTwoMoveOneType = moveOneType;
playerTwoMoveOneValue = moveOneValue;
playerTwoMoveTwoType = moveTwoType;
playerTwoMoveTwoValue = moveTwoValue;
playerTwoMoveThreeType = moveThreeType;
playerTwoMoveThreeValue = moveThreeValue;
}
}
//build out valid move type checker as helper function
function isValidMoveType(moveType){
return (moveType === ‘rock’) || (moveType === ‘paper’) || (moveType === ‘scissors’);
}
//build out move value checker as helper function
function isValidMoveValue(moveValue){
return (moveValue >= 1) && (moveValue <= 99);
}