Javascript TypeError: can't convert undefined to object

javascript, object, typeerror, undefined

Solution

The error is because you did not define `horizont` as an Array. You are using a comma to separate your variable so it is undefined. It does not use the `new Array()` from vertikal.

If you take your code

var horizont, vertikal = new Array ()

And write it out to use multiple variable, the error would pop out.

var horizont;
var vertikal = new Array();

You need to specify both as Arrays.

var horizont = [], 
    vertikal = [];

Problem

``` var horizont, vertikal = new Array () for (var i=0; i < 9; i++) { horizont[i] = new Array (); vertikal[i] = new Array () } ``` That's what the console told me: TypeError: can't convert undefined to object ``` horizont[i] = new Array (); ``` (if I would erase it from the code he says the same with vertikal ) except from some other empty strings getiing born it's the beginning of my code... where is the mistake? Is it so ovious that I don't see it?

Original source