title: Getting the length of a nested JSON array in JavaScript
body: <pre><code>            {
              "wordsacross": [
                  {"ACHE": [
                      { "letter":"A" , "square":"A1" }, 
                      { "letter":"C" , "square":"A2" }, 
                      { "letter":"H" , "square":"A3" },
                      { "letter":"E" , "square":"A4" }
                  ]},
                  {"OPT": [
                      { "letter":"O" , "square":"A6" }, 
                      { "letter":"P" , "square":"A7" }, 
                      { "letter":"T" , "square":"A8" }
                  ]}
              ],
              "wordsdown": [
                  {"ALPHA": [
                      { "letter":"A" , "square":"A1" }, 
                      { "letter":"L" , "square":"B1" }, 
                      { "letter":"P" , "square":"C1" },
                      { "letter":"H" , "square":"D1" },
                      { "letter":"A" , "square":"E1" }
                  ]},
                  {"BRO": [
                      { "letter":"B" , "square":"G1" }, 
                      { "letter":"R" , "square":"H1" }, 
                      { "letter":"O" , "square":"I1" }
                  ]}
              ]
              }
  
              $.ajax({
                  type: "POST",
                  url: "query.words.php",
                  data: { puzzleid: vPuzzleId },
                  async: false
              }).done(function( msg ) {
                  vWords = JSON.parse( msg );
                  console.log(vWords);
                  console.log("There are "+vWords["wordsacross"].length+" words across");
                  for(var i=0;i&lt;vWords["wordsacross"].length;i++)
                  {
                      console.log( vWords["wordsacross"][i].length );
                      console.log( vWords["wordsacross"][i][0]["square"] );
                  }
              });
  </code></pre>
  
  <p>I am trying to print out the content of all square items to the console. Both of my attempts at console.log are coming out undefined. How am I to access each square and print it to the console?</p>
  
  <p>Thanks in advance...</p>