title: How to access a value in a array
body: <p>I need to access the wall array inside the C variable. I can find what c is, but not what any specific value of c. I probably made a mistake of how to access the value from this array, but I tried to do c[3], and it always says undefined. This is the full program link <a href="https://editor.p5js.org/Meowmeow/sketches/b4AhGA4xH" rel="nofollow noreferrer">https://editor.p5js.org/Meowmeow/sketches/b4AhGA4xH</a>.</p>
  <pre><code>function index(i, j) {
  
    if (i &lt; 0 || j &lt; 0 || i &gt; cols - 1 || j &gt; cols - 1) {
      return -1;
    }
    return i + j * cols
  }
  
  function Cell(i, j) {
  
  
    this.visited = false;
    this.i = i;
    this.j = j;
    this.walls = [true, true, true, true];
    this.checkNeighbors = function() {
      var neighbors = []
      var top = grid[index(i, j - 1)]
      var right = grid[index(i + 1, j)]
      var left = grid[index(i - 1, j)]
      var bottom = grid[index(i, j + 1)]
      var Wall = this.walls;
      
      var wall=[]
      wall.push(i,j,Wall)
      
      
      if (top &amp;&amp; !top.visited) {
        neighbors.push(top);
      }
  
      if (right &amp;&amp; !right.visited) {
        neighbors.push(right);
      }
      if (bottom &amp;&amp; !bottom.visited) {
        neighbors.push(bottom);
      }
      if (left &amp;&amp; !left.visited) {
        neighbors.push(left);
      }
  
      if (neighbors.length &gt; 0) {
        var r = floor(random(0, neighbors.length))
        return neighbors[r];
      } else {
        return undefined;
      }
  
    }
  
    this.highlight = function() {
      var x = this.i * w;
      var y = this.j * w;
      noStroke();
      fill(0, 0, 255, 100)
      rect(x, y, w, w);
  
    }
    this.show = function() {
      var x = this.i * w;
      var y = this.j * w;
      stroke(255);
      noFill();
  
      if (this.walls[0]) {
        line(x, y, x + w, y);
      }
      if (this.walls[1]) {
        line(x + w, y, x + w, y + w);
      }
  
      if (this.walls[2]) {
        line(x + w, y + w, x, y + w);
      }
      if (this.walls[3]) {
        line(x, y + w, x, y);
      }
  
      if (this.visited) {
        fill(255, 0, 255, 100);
        noStroke();
        rect(x, y, w, w);
      }
    }
  };
  
  
  
  
  
  
  function removeWalls(a, b) {
    var x = a.i - b.i;
    if (x === 1) {
      a.walls[3] = false;
      b.walls[1] = false;
    } else if (x === -1) {
      a.walls[1] = false;
      b.walls[3] = false;
    }
    var y = a.j - b.j;
  
    if (y === 1) {
      a.walls[0] = false;
      b.walls[2] = false;
    } else if (y === -1) {
      a.walls[2] = false;
      b.walls[0] = false;
    }
  
  
  }
  
  function draw() {
    background(51);
    for (var i = 0; i &lt; grid.length; i++) {
      grid[i].show()
    }
  
  
    //Step One
    current.visited = true;
    current.highlight();
  
    var next = current.checkNeighbors()
    if (next) {
      next.visited = true;
  
      //Step 2
      stack.push(current);
      check.push(current)
  
      //Step 3
      removeWalls(current, next) 
      {}
  
  
      //Step 4 
      current = next;
    } else if (stack.length &gt; 0) {
      current = stack.pop();
  
    }
  
  
    if (stack[0] === undefined) {
      fill(0, 105, 100)
      rect(0, 0, w, w)
      rect(width - w, height - w, w, w)
      frameRate(8)
    
      
      var c = check.find(cell =&gt; cell.i == ~~(k/w) &amp;&amp; cell.j == ~~(m/w));
        
  
      console.log(c)
      if(c===undefined)
  </code></pre>
  <p>I'm not sure if I needed to put in this much of the code, but I didn't want to leave anything important out.</p>