You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
498 B
18 lines
498 B
function vierInSpalte(arr){
|
|
var Gewinner = 0;
|
|
//Spieler Gruen
|
|
for (let i = 0; i < arr.length - 3; i++) {
|
|
if (arr[i] === 1 && arr[i + 1] === 1 && arr[i + 2] === 1 && arr[i + 3] === 1) {
|
|
Gewinner = 1;
|
|
}
|
|
}
|
|
//Spieler Rot
|
|
for (let i = 0; i < arr.length - 3; i++) {
|
|
if (arr[i] === 2 && arr[i + 1] === 2 && arr[i + 2] === 2 && arr[i + 3] === 2) {
|
|
Gewinner = 2;
|
|
}
|
|
}
|
|
return Gewinner;
|
|
|
|
}
|
|
module.exports = vierInSpalte;
|