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.

19 lines
504 B

  1. function vierInSpalte(arr){
  2. var Gewinner = 0;
  3. //Spieler Gruen
  4. for (let i = 0; i < arr.length - 3; i++) {
  5. if (arr[i] === 1 && arr[i + 1] === 1 && arr[i + 2] === 1 && arr[i + 3] === 1) {
  6. Gewinner = 1;
  7. }
  8. }
  9. //Spieler Rot
  10. for (let i = 0; i < arr.length - 3; i++) {
  11. if (arr[i] === 2 && arr[i + 1] === 2 && arr[i + 2] === 2 && arr[i + 3] === 2) {
  12. Gewinner = 2;
  13. }
  14. }
  15. return Gewinner;
  16. }
  17. module.exports = vierInSpalte;