'Why is my output incorrect? Two player game, javascript

INSTRUCTIONS:

Two players are playing a game of Tower Breakers! Player 1 always moves first, and both players always play optimally.The rules of the game are as follows:

Initially there are n towers. Each tower is of height m. The players move in alternating turns. In each turn, a player can choose a tower of height x and reduce its height to y, where 1 <= y < x and y evenly divides x. If the current player is unable to make a move, they lose the game. Given the values of n and m, determine which player will win. If the first player wins, return 1. Otherwise, return 2.

Example input: 2 2 2 1 4

Example output: 2 1

ATTEMPT:

function towerBreakers(n, m) {
    // Write your code here
    let res = 0;

    for (let i = 0; i < n; i++) {
        res >= m[i];
    }

    // case when Player 1 is winner
    if (res === 0 || n % 2 == 0)
        return "1";

    // when Player 2 is winner
    else
        return "2";
}

CURRENT OUTPUT:

My current output is 1 1 instead of 2 1 or 1 2 (can't be a duplicate of both numbers like it is right now).



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source