Skip to content

Instantly share code, notes, and snippets.

@spikeheap
Created July 5, 2014 16:11
Show Gist options
  • Select an option

  • Save spikeheap/89e140f018f24dd3e070 to your computer and use it in GitHub Desktop.

Select an option

Save spikeheap/89e140f018f24dd3e070 to your computer and use it in GitHub Desktop.
Stupid JavaScript
// The tests.
it('test', function() {
var a1 = [];
a1.push({x:0, y:2});
a1.push({x:1, y:2});
a1.push({x:2, y:2});
a1.push({x:3, y:3});
expect(a1.indexOf({x:0, y:2})).toBe(true);
});
@richdouglasevans

Copy link
Copy Markdown
  var toIndexOfKey = function(cell) { return cell.x + ":" + cell.y };
  var answer = a1.map(toIndexOfKey).indexOf(toIndexOfKey({x:0, y:2}));
  console.log(answer);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment