var toplamgun = 0; var toplampazar = 0; for (var yıl = 1900; ++yıl < 2001;){ for(var ay= 0; ++ay<13;){ if (ay == 2){ } else{ var eklenecekgun = AydakiGunler[ay] // error is here toplamgun += eklenecekgun yenigunindex = toplamgun % 7; if(yenigunindex == 6){ toplampazar += 1; } } } } console.log(toplampazar); var AydakiGunler = [0,31,0,31,30,31,30,31,31,30,31,30,31]; cant get an item from an array by index
here is the error TypeError: Cannot read property '1' of undefined
im trying to https://projecteuler.net/problem=19
AydakiGunlerisn't defined until after the code is run - var declarations are hoisted, but not the value