function resetGarden(state, garden) {
  const name = garden.name || state.name;
  const width = garden.width || state.width;
  const height = garden.height || state.height;
  const squares = garden.squares || [];

  if (!squares.length) {
    const numSquares = width * height;

    for (let i = 0; i < numSquares; i++) {
      squares.push(newSquare);
    }
  }

  return Object.assign({}, state, { name, width, height, squares });
}
// replace the existing garden with a new one
replace the existing garden with a new one
replace the existing garden with a new one
function resetGarden(state, garden) {
  const name = garden.name || state.name;
  const width = garden.width || state.width;
  const height = garden.height || state.height;
  const squares = garden.squares || [];
  if (!squares.length) {
    const numSquares = width * height;
    for (let i = 0; i < numSquares; i++) {
      squares.push(newSquare);
    }
  }
  return Object.assign({}, state, { name, width, height, squares });
}
function resetGarden ( state , garden ) { const name = garden . name || state . name ; const width = garden . width || state . width ; const height = garden . height || state . height ; const squares = garden . squares || [ ] ; if ( ! squares . length ) { const numSquares = width * height ; for ( let i = 0 ; i < numSquares ; i ++ ) { squares . push ( newSquare ) ; } } return Object . assign ( { } , state , { name , width , height , squares } ) ; }
replace the existing garden with a new one
replace the existing garden with a new one