Skip to content

Instantly share code, notes, and snippets.

@renatocassino
Created August 8, 2018 01:52
Show Gist options
  • Save renatocassino/b770cdec530954d42d7e6529bfbf9180 to your computer and use it in GitHub Desktop.
Save renatocassino/b770cdec530954d42d7e6529bfbf9180 to your computer and use it in GitHub Desktop.
2048-addNumber-01.js
const addNumber = (board, point, number=2) => {
return board.map( // Iterate over columns
(line, columnIdx) => line.map((block, lineIdx) => // Iterate over line
// If column and line index is equals, return 2, else return the number
columnIdx === point[0] && lineIdx === point[1] ? number : block
));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment