인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

허니콤보's profile image
허니콤보

asked

Learning JavaScript while making web games

틱택토 질문있습니다.

Written on

·

175

0

왼쪽위에서 대각선 검사할때

가운데 줄과 가운데 칸이 을 빼면 0 이되는데

if문에서 왜 2가 될경우로 조건문을 거나요 ..?

        //대각선 검사(왼쪽 위)
        if(Math.abs(colName - rowName) == 2){
            if(
            allRow[0][2].textContent == x &&
            allRow[1][1].textContent == x &&
            allRow[2][0].textContent == x 
            ){
                console.log('왼쪽 위 완성');
                var full = true;                
            }
       }   
javascript

Answer 1

0

zerocho님의 프로필 이미지
zerocho
Instructor

if ([0, 2].includes(Math.abs(colName - rowName))) {

}

로 수정하시면 되겠습니다.

허니콤보's profile image
허니콤보

asked

Ask a question