*Javascript Requirements: You are not creating a visualization of Conway's Game of Life. You are simply writing...
Fantastic news! We've Found the answer you've been seeking!
Question:
*Javascript
Requirements:
You are not creating a visualization of Conway's Game of Life. You are simply writing a function named stepBoard that takes a 2D array of booleans and returns a 2D array of booleans. That's it.
Put JavaScript code in file named conway.js.
Your file must contain a top-level function named stepBoard. You may write as many other helper functions as you want, but we will only test your code by calling stepBoard.
stepBoard takes a board as input. A board is a 2D array of booleans. true means the cell is alive, false means it's dead. For example, this board:
would be represented as [[true, false, true], [false, true, false]].
- stepBoard must return (not print) the input board advanced one step in the simulation. For example,
- stepBoard([[true, false, true], [false, true, false]])
should return
[[false, true, false], [false, true, false]] - You may assume that all input boards will be rectangular, meaning that every row will have the same number of columns. Note that the empty board, a board with one empty row, and a board with one empty column are all valid rectangular boards. In these cases, stepBoard should simply return the inputted board.
- The code must only use plain JavaScript: no npm modules, no NodeJS standard library modules, no browser APIs, and no frameworks or outside libraries.
- It should not include any import/export or NodeJS require statements.
- stepBoard must be a pure function, meaning it should cause no side effects (including mutating the input board) and always return the same output when called with the same input. If this doesn't make sense, see here for more details.
Related Book For
Posted Date: