let field = document.createElement('div'); document.body.appendChild(field); field.classList.add('field'); //Π Π°Π·Π±ΠΈΠ²Π°Π΅ΠΌ Π±Π»ΠΎΠΊ Π½Π° ΡΡΠ΅ΠΉΠΊΠΈ for (let i=1; i<101; i++) { let excel = document.createElement('div'); field.appendChild(excel); excel.classList.add('excel'); } //ΠΠ°ΡΠΌ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΡ ΠΊΠ°ΠΆΠ΄ΠΎΠΉ ΡΡΠ΅ΠΉΠΊΠ΅ let excel = document.getElementsByClassName('excel'); let x = 1, y = 10; for (let i=0; i<excel.length; i++) { if (x>10){ x=1; y--; } excel[i].setAttribute('posX', x); excel[i].setAttribute('posY', y); x++; } fuction generateSnake() { let posX = Math.round(Math.random() * (10 - 1) + 1); let posY = Math.round(Math.random() * (10 - 1) + 1); return [posX, posY]; } let coordinates = generateSnake(); console.log(coordinates); console.log(coordinates[0]); console.log(coordinates[1]);
Closed due to the fact that the essence of the question is not clear to the participants of Kosta B. , Yaant , Kirill Korushkin , 0xdb , LFC on 15 Apr at 8:32 .
Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .
- Usually, the error still indicates the row and column number and everything is pretty obvious there. - Alexey Ten
|