Javascript for json object nothing shows in the html page? -


i'm following js tutorial, , i've faced problem: list not showing in browser.

i checked script part, it's okay. didn't find error in code.

the output on page's browser should somthing list:

*facebook:... *instagram:... 

script:

var info= {   "full_name": "tim berner ",   "tile": "staff author",   "links": [     {"facebook": "https://web.facebook.com/"},     {"instagram": "https://www.instagram.com/"}   ] };  var output = ''; (var = 0; <= info.length; i++){   (key in info.links[i]){     if (info.links[i].hasownproperty(key)){       output += '<li>' +         '<a href= "' + info.links[i] [key] +          ' ">' + key + '</a> ' +         '</li>' ;      } //hasownproperty   } //for each object } //for each array element   var update = document.getelementbyid('links'); update.innerhtml = output; 

you missing .links in statement condition. see working javascript code below:

var info = {     "full_name": "tim berner ",     "tile": "staff author",     "links": [         { "facebook": "https://web.facebook.com/" },         { "instagram": "https://www.instagram.com/" }     ] };  var output = ''; (var = 0; <= info.links.length; i++) {     (key in info.links[i]) {         if (info.links[i].hasownproperty(key)) {             output += '<li>' +                 '<a href= "' + info.links[i][key] +                 ' ">' + key + '</a> ' +                 '</li>';         }//hasownproperty     }//for each object }//for each array element  var update = document.getelementbyid('links'); update.innerhtml = output; 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -