+ 3
Uncaught TypeError: Cannot read property '0' of undefined[es6 learning]
That error occurs most often in my codes... I spent an hour thinking what's wrong. I'm trying to assign each of the divs an action function changing it's color to black and I'm getting an annoying error: Cannot read property '0' of undefined. Please help, my code: https://code.sololearn.com/WZ7tjp0roE7X/#html
6 Antworten
+ 3
Hi Amadeus, area getter is called without brackets in the lesson, but declared with
+ 5
but you're for sure right: not this.cells, but this.Cells
+ 4
Mike Choy Oh thanks, now I understood. As in c#
+ 3
Hi Amadeus
Just had a quick look, and its failing on this.cells should it be this.Cells?
for(let m=0; m<this.yCount; m++){
$("body").append("<div></div>");
this.cells[l][m] = $("body div").last();
$(this.cells[l][m]).addClass("cell");
$(this.cells[l][m]).css({
+ 2
Hi, Mike Choy
Thanks for support, but in the lesson "class methods"
https://www.sololearn.com/learn/518/?ref=app
they used the following getter for the calcArea method...
get area() {
return this.calcArea();
}
calcArea() {
return this.height * this.width;
}
+ 1
Hi Amadeus
And finally you are calling your getters wrong;
Should be
board.Create;
board.AllowMark;
no brackets as its not a method.
It runs and paints one big long vertical bar, so some more work to do
but hopefully that gets you going again