jinux127 2022. 2. 15. 21:54

function solution9(loc){
    let move_types= [
        [-2,-1],
        [-2,1],
        [2,-1],
        [2,1],
        [-1,-2],
        [1,-2],
        [-1,2],
        [1,2]
    ]
    let count = 0;
    let x = parseInt(loc.split('')[0].charCodeAt()-96);
    let y = parseInt(loc.split('')[1]);
    
    for (const move of move_types) {
        count++;
        console.log(`x +move[0]: ${x +move[0]}`)
        console.log(`y +move[1]: ${y +move[1]}`)
        if(x + move[0] < 1 || y + move[1] < 1 || x + move[0] > 8 || y + move[1] > 8) count--;
    }
    console.log(count);
}