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.

14 lines
652 B

  1. function vierDiagonalRechts(allSpaltenArray) {
  2. var Gewinner =0;
  3. for (let i = 0; i <= allSpaltenArray.length -3; 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. }
  8. if (allSpaltenArray[j][i]===2 && allSpaltenArray[j+1][i+1]===2 && allSpaltenArray[j+2][i+2]===2 && allSpaltenArray[j+3][i+3]===2) {
  9. Gewinner = 2;
  10. }
  11. }
  12. }
  13. return Gewinner;
  14. }
  15. module.exports = vierDiagonalRechts;