Skip to content

Instantly share code, notes, and snippets.

@alexpilugin
Created July 9, 2017 10:31
Show Gist options
  • Save alexpilugin/8b5b045fd44a64293cbb62055e90c4bb to your computer and use it in GitHub Desktop.
Save alexpilugin/8b5b045fd44a64293cbb62055e90c4bb to your computer and use it in GitHub Desktop.
function remove(array, index) {
return array.slice(0, index).concat(array.slice(index + 1));
}
Array.prototype.remove = function (index) {
return this.slice(0, index).concat(this.slice(index + 1));
}
//random 0 or 1:
Math.floor(Math.random()+0.5)
//shuffle:
Array.prototype.getShuffledCopy = function(){
var copy = this.slice();
return copy.sort(function(a,b) { return Math.floor(Math.random()+0.5) })
}
//function's arguments:
function sum() {
var result = 0;
for (var i = 0; i < arguments.length; i++) {
var num = isNaN(Number(arguments[i])) ? 0 : Number(arguments[i]);
result += num;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment