Created
August 8, 2018 01:52
-
-
Save renatocassino/b770cdec530954d42d7e6529bfbf9180 to your computer and use it in GitHub Desktop.
2048-addNumber-01.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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