[Logo]
Forums Register Login
Can't figure out error
Here is the code



I get the error Cannot read property 0 of undefined. What does this mean and how can I fix it?
What is the purpose of line 12? Appending a string to an array? Does that make sense?

I'd advise breaking this down into multiple functions that each perform one duty.
tmpArr is an array. I'm making an x*x array.
 

Bear Bibeault wrote:Appending a string to an array? Does that make sense?

 
Okay, so I figured out my original problem. But now I have an even bigger problem.

First of all, I am trying to make a javascript implementation of Conway's Game of Life(CGoL). Now, for CGoL to work, you have to update all of the squares once, and only once without letting an update of an adjacent square impact it. Basically, I have to update all of the squares at the same time. How do I do that?

Here's my updated code:
 

Rocky Rocha wrote:Basically, I have to update all of the squares at the same time. How do I do that?



You stash the updated values somewhere else, and then when you've calculated all of them, you copy them back to where the original values are.

Or alternatively: you copy all of the original values somewhere else, and then use the somewhere-else values to compute the new original values.
Thanks that works, but now I have another problem. How would I push an empty array into an array? Specifically, how do I push [] into simView.grid?
So right now my issue is that I cannot read the value of the 2D array. Here is my code.



What does this error mean, and how can I fix it?
I found a beautiful pie. And a tiny ad:
ScroogeXHTML 7.1 - RTF to HTML5 / XHTML converter
https://coderanch.com/t/690611/ScroogeXHTML-RTF-HTML-XHTML-converter


This thread has been viewed 255 times.

All times above are in ranch (not your local) time.
The current ranch time is
Feb 21, 2018 18:07:48.