Daily Coding Challenge - Checkerboard

Tell us what’s happening:

Hi all, I need some help with this challenge.
I’m unsure what’s going on with the test cases for it, specifically testcases 3 and 4.

Test case 3 states: “createBoard([2, 10]) should return [[“X”, “O”, “X”, “O”, “X”, “O”, “X”, “O”, “X”, “O”], [“O”, “X”, “O”, “X”, “O”, “X”, “O”, “X”, “O”, “X”]]”

…which is incorrect, as the very last character in the first list matches the very first character in the second list, which goes against the instructions.

Any help would be appreciated.
Thank you!!

Your code so far

function createBoard(dimensions) {
  let currCharacter = "X";
  let board = [];

  for (let i = 0; i < dimensions[0]; i++) {
    let row = [];
    for (let j = 0; j < dimensions[1]; j++) {
      row.push(currCharacter);
      currCharacter = (currCharacter === "X") ? "O" : "X";
    }
    board.push(row);
  }

  return board;
}

console.log(createBoard([3, 3])); // should return [["X", "O", "X"], ["O", "X", "O"], ["X", "O", "X"]].
console.log(createBoard([6, 1])); // should return [["X"], ["O"], ["X"], ["O"], ["X"], ["O"]].
console.log(createBoard([2, 10])); // should return [["X", "O", "X", "O", "X", "O", "X", "O", "X", "O"], ["O", "X", "O", "X", "O", "X", "O", "X", "O", "X"]].
console.log(createBoard([5, 4])); // should return [["X", "O", "X", "O"], ["O", "X", "O", "X"], ["X", "O", "X", "O"], ["O", "X", "O", "X"], ["X", "O", "X", "O"]]

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36

Challenge Information:

Daily Coding Challenge - Checkerboard
https://www.freecodecamp.org/learn/daily-coding-challenge/2025-12-18

Welcome to the forum @xsussicax !

Should currCharacter always be “X” going into the inner loop?

Where in the instruction are you seeing that? Remember, the tests themselves are instructions, too, in that they are telling you what should be returned.

Happy coding!

Can explain what he is trying to convey

Welcome to the forum @VarunKaivalya !

You are free to provide you own help to the OP. :slight_smile:

Happy coding!