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.

13 lines
632 B

  1. function vierDiagonalLinks(allSpaltenArray) {
  2. var Gewinner =0;
  3. for (let i = 3; i <= allSpaltenArray.length; i++) {
  4. for (let j = 0; j <= allSpaltenArray[0].length -3; j++) {
  5. if (allSpaltenArray[j][i]===1 && allSpaltenArray[j+1][i-1]===1 && allSpaltenArray[j+2][i-2]===1 && allSpaltenArray[j+3][i-3]===1) {
  6. Gewinner = 1;
  7. }if (allSpaltenArray[j][i]===2 && allSpaltenArray[j+1][i-1]===2 && allSpaltenArray[j+2][i-2]===2 && allSpaltenArray[j+3][i-3]===2) {
  8. Gewinner = 2;
  9. }
  10. }
  11. }
  12. return Gewinner;
  13. }
  14. module.exports = vierDiagonalLinks;