In the solution to the Cumulative Project: Rock, Paper, Scissors x99, the person writes the below code to return variable TIE if the move value and type are the same.
I’m just confused why I fail the test if I use “return ‘Tie’;” and pass the test when I use “return TIE;” when const TIE = ‘Tie’.
If the explanation of my confusion is not clear, please let me know.
Link to video here, code can be see at 26:08.
const evaluateMove = (p1t, p1v, p2t, p2v) => {
//make sure all moves are present
if (!p1t || !p1v || !p2t || !p2v) {
return null;
}
//if types are the same, winner is based on higher value
if (p1t === p2t) {
if (p1v === p2v) {
return TIE; //works when using variable TIE, but not string 'tie'
}
return p1v > p2v ? P1 : P2;
}
switch(p1t) {
case rock:
return p2t === scissors ? P1 : P2;
case paper:
return p2t === rock ? P1 : P2;
case scissors:
return p2t === paper ? P1 : P2;
}
};```