Skip to content

Instantly share code, notes, and snippets.

@eldad87
eldad87 / JavascriptBinarySearchArrayPrototype
Last active October 7, 2017 23:12
Add Binary Search capabilities to native Array
/**
* Binary search
*
* @example:
* var arr = [0, 2];
* arr.binarySearch(0) -> true
* arr.binarySearch(2) -> true
* arr.binarySearch(-1)-> false
* arr.binarySearch(1) -> false
* arr.binarySearch(3) -> false
@eldad87
eldad87 / gist:e9fee573f06fe09bcaf0afdf7e35bcf5
Last active October 10, 2017 16:50
JavaScript - Checkers
/**
* Pawn object
* @param Player player
* @param string role pawn || queen
* @constructor
*/
function Pawn(player, role) {
this.player = player;
this.maxStep = 1;
this.role = role || 'pawn';