var bord = [1, 2, 3, 4, 5, 6];
var size = bord.length;
var num1 = [1, 2, 6];
var tru = num1.sort(function (a, b) {return a - b; });
var four = tru[1] - tru[0],
    fourT = tru[2] - tru[1];



var out;
if (four === 1 && fourT === 1) {
    var out = 4;
} else if (four === 1 || fourT === 1) {
    var out = 2;
} else {
    var out = 0;
}
var out;