ordered list; working with javascript and json

I’m a junior web developer and I want to understand what json file does, as I have no idea. So I am following a tutorial from lynda.com

It seems very simple, I want to display the array elements within the variable info, but for some reason, it’s adding another count after each item of the array!!! I have checked and compared the code with the tutorial, and it’s still appearing wrong.

I have added the code on JSFiddle:


Those are my loops:

for (var i = 0; i <= info.links.length; i++) {
    for (key in info.links[i]) {
        if (info.links[i].hasOwnProperty(key)) {
            output += '<li>' +
                '<a href = "' + info.links[i][key] +
                '">' + key + '</a>' +
        } // hasOwnProperty ckeck
    } //for each object
} //for each array element

I guess it is what it must be wrong….

Thank you!!!!

Source: json

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.