Stackoverflow - How to loop through Nested Json Array with (JavaScript) for loop and display the text

http://stackoverflow.com/q/11458355/918414

by Damith Nuwan Sampath

HTML

<div id="results"></div>



















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































<script>

/* by: thinkingstiff.com
license: http://creativecommons.org/licenses/by-nc-sa/3.0/us/ */

var headerCaption = 'How to loop through Nested Json Array with (JavaScript) for loop and display the text',
    headerUri = 'http://stackoverflow.com/q/11458355/918414';
    
document.body.insertAdjacentHTML( 
    'afterBegin',
      '<a href="' + headerUri + '" '
    + 'target="_top" '
    + 'onmouseover="this.style.opacity=\'.95\'" '
    + 'onmouseout="this.style.opacity=\'1\'" '
    + 'style="'
        + 'background-color: black;'
        + 'background-image: linear-gradient( top, rgba( 255, 255,...

JavaScript

var fielditems =[
     [["News Tips"],["Opinions"],["MedMinutes"]],
     [["Yes"],["No"],["Maybe"]],
     [["How"],["Why"],["When"]]
    ],
    html = '';

for( var itemIndex = 0; itemIndex < fielditems.length; itemIndex++ ){
    var itemSetValues = fielditems[itemIndex];
    for(var setIndex = 0; setIndex < itemSetValues.length; setIndex++ ){
        var itemValue = itemSetValues[setIndex];
        for(var valueIndex = 0; valueIndex < itemValue.length; valueIndex++ ){
            html += itemValue[valueIndex] + '<br />';
        }
    }
}

document.getElementById( 'results' ).innerHTML = html;