Daily Coding Challenge - Bucket Fill

Tell us what’s happening:

Seems like the test cases do not jive with the requirements. The requirements say only horizontally or vertically adjacent cells of the same value should be updated, but the test cases are looking for other updates, of which I do not see a clear pattern.

Your code so far

function bucketFill(grid, [row, col], newValue) {
  //log the values of the input
  for (let i = 0; i < grid.length; i++){
    console.log(`${grid[i]}`);
  }
  console.log(`Starting point: ${row}, ${col}`);
  console.log(`newValue: ${newValue}`);
  let oldValue = grid[row][col];
  console.log(`oldValue: ${oldValue}`);
  

  //add conditionals to check values of +1/-1 of row and column

  for (let i = 0; i < grid.length; i++){
    for (let j = 0; j < grid[i].length; j++){
      console.log(`cell: ${i}, ${j}\nvalue: ${grid[i][j]}`);
      if (
        ((i == row -1 || i == row || i == row +1) && j == col) 
        ||((j == col -1 || j == col || j == col+1) && i == row)
        && grid[i][j] == oldValue){
          console.log(`inside the if`);
        grid[i][j] = newValue;
      }
    }
  }

  for (let i = 0; i < grid.length; i++){
    console.log(`${grid[i]}`);
  }

  return grid;
}

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

Challenge Information:

Daily Coding Challenge - Bucket Fill

https://www.freecodecamp.org/learn/daily-coding-challenge/2026-07-05

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6a1d9f98e819ed70a0e994db.md at main · freeCodeCamp/freeCodeCamp · GitHub

Welcome to the forum @shane.gladden1,

Think of a “connect the dots” game. Starting from the [row, col] position, any cell that has an adjacent character that’s the same as newValue qualifies as being connected.

Happy coding