I got this code from online and it works perfectly from the commented line down. It shows each word in a div. I added the array etc above the commented part but when I run that it shows every word in a div.

I have no idea why.

    var carArray = ['Saab', 'Volvo', 'BMW', 'GMC', 'Nissan', 'Ford'];
    var cars = carArray.toString();

    //var cars = 'Saab,Volvo,BMW,GMC,Nissan,Ford'.split(",");
    for (var c in cars)

        var newElement = document.createElement('div');
        newElement.id = cars[c]; newElement.className = "car";
        newElement.innerHTML = cars[c];