Skip to content

Commit

Permalink
try modify a Function: initializewithpattern to corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel-lope authored May 24, 2024
1 parent 9d9f0d3 commit 2fb22f2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function setup() {
function make2DArray(cols, rows) {
let arr = new Array(cols);
for (let i = 0; i < arr.length; i++) {
arr[i] = new Array(rows);
arr[i] = new Array(rows).fill(0);
}
return arr;
}
Expand All @@ -96,8 +96,8 @@ function randomizeGrid() {
function initializeWithPattern(pattern) {
let startX = Math.floor((cols - pattern.length) / 2);
let startY = Math.floor((rows - pattern[0].length) / 2);
for (let i = 0; i < cols; i++) {
for (let j = 0; j < rows; j++) {
for (let i = 0; i < pattern.length; i++) {
for (let j = 0; j < pattern[i].length; j++) {
grid[startX + i][startY + j] = pattern[i][j];
}
}
Expand Down

0 comments on commit 2fb22f2

Please sign in to comment.