JavaScript game of life implementation