Created
July 9, 2017 10:31
-
-
Save alexpilugin/8b5b045fd44a64293cbb62055e90c4bb to your computer and use it in GitHub Desktop.
This file contains 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
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