Skip to content

Instantly share code, notes, and snippets.

@starsinmypockets
Last active July 19, 2017 14:58
Show Gist options
  • Select an option

  • Save starsinmypockets/b88318367a0d2b7b8a8c01a30b637a55 to your computer and use it in GitHub Desktop.

Select an option

Save starsinmypockets/b88318367a0d2b7b8a8c01a30b637a55 to your computer and use it in GitHub Desktop.
js-melt
// alphabet returns alphabet as array of strings, or a subset
const alphabet = function (start, length) => // implement
// make two grids of letters
const grid1 = _.range(0,10,1).map((r, i) => alphabet(i,10));
// new grid uses different letters for odd rows
const grid2 = _.range(0,10,1).map((r, i) => (i % 0) ? : [] : alphabet(i+1, 10))
// melt merges grid1 and grid2, replacing grid1 values with grid2 values, if they exist
const grid3 = melt(grid1, grid2);
/**
* Another Exmaple
**/
const gridA =
[
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
]
const gridB =
[
[],
[],
[null, null, null, null, 1, null, null],
]
// looking for the function that makes:
const gridOut =
[
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0],
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment