0
체커 게임을 만들려고하고 있고 게임 규칙을 만들 때 TypeError를 실행 중입니다.자바 스크립트에서 객체를 호출 할 때 TypeError가 발생합니다.
var tryAgain = function(){
return {
pcolor : function() {
position1 = prompt("chose either 'wht' or 'red'");
//attemptMove(getMove(position1,position2).startRow, getMove(position1,position2).startCol, getMove(position1,position2).endRow, getMove(position1,position2).endCol);
},
invalid : function() {
position2 = prompt("Can't move there, try again");
attemptMove(getMove(position1,position2).startRow, getMove(position1,position2).startCol, getMove(position1,position2).endRow, getMove(position1,position2).endCol);
}
};
}
var attemptMove = function(row1, col1, row2, col2)
{
if(board[row1][col1] != 'wht' || board[row1][col1] != 'red'){
tryAgain.pcolor();
}
if(board[row2][col2] != ' X '){
tryAgain.invalid();
}
}
잘 작동하지만 꽤 왜 이해가 안돼 ??? 객체에 메서드를 호출하지 않았습니까? TryAgain()을 다시 호출해야하는 이유는 무엇입니까? –
업데이트 된 답변과 올바르게 표시하는 것을 잊지 마세요. – Mutmatt