function changeIfEqual(variable, value, newValue){
    return variable == value ? newValue : variable;
}
Array.prototype.contains = function(obj){
    var i = this.length;
    while(i--)
        if(this[i] == obj)
            return true;
    return false;
    
    for(var i in this)
        if(this[i] == obj)
            return true;
    return false;
}

function changeIfEqual(variable, value, newValue){
    return variable == value ? newValue : variable;
}
function negate(func) {
	return function(x) {
		return !func(x);
	};
}

function equal(el1, el2){
	return el1 == el2;
}

function greaterThen(el1, el2){
	return el1 > el2;
}

function lessThen(el1, el2){
	return el1 < el2;
}

Array.prototype.sum = function(total = 0) {
	this.forEach(function (number){
		total += number;
	});
	return total;
}

Array.prototype.max = function(numbers) {
	var max, j = 0;
	this.forEach(function (number) {
		max = equal(j++, 0) ? number : (greaterThen(max, number) ? max : number);
	});
	return max;
}

Array.prototype.min = function(numbers) {
	var min, j = 0;
	this.forEach(function (number) {
		min = equal(j++, 0) ? number : (lessThen(min, number) ? min : number);
	});
	return min;
}

Array.prototype.head = function(){//existuje shift - ale ten vymazava
	this.length > 0 ? this[0] : false;
}

Array.prototype.last = function(){//existuje pop - ale ten vymazava
	this.length > 0 ? this[this.length - 1] : false;
}

Array.prototype.merge = function(){
	return this.concat().sort();
}

Array.prototype.product = function(func, result = []){
	this.forEach(function(element){
		result.push(func(element));
	});
	return result;
}

Update Utils.js