title: return each variable outside $.each function
body: <p>I'm a bit new to multidimensional arrays in JSON and I've been banging my head with something for a while now. Let me post my code below</p>
  
  <p>JSON:</p>
  
  <pre><code>{
      "easy_questions": [
          {
              "q": "Question 1",
              "a": [
                  {"option":"Answer 1",   "correct": false},
                  {"option":"Answer 2",   "correct":true},
                  {"option":"Answer 3",   "correct":false},
                  {"option":"Answer 4", "correct": false}
              ],
              "image": false,
              "source": "dsa"
          }, 
          {
              "q": "Question 2",
              "a": [
                  {"option":"Answer 1",   "correct": false},
                  {"option":"Answer 2",   "correct":true},
                  {"option":"Answer 3",   "correct":false},
                  {"option":"Answer 4", "correct": false}
              ],
              "image": false,
              "source": false
          }, // this goes on for about 7 more questions...
      ], 
      "step2_easy": [
          {
              "q": "Question 1",
              "a": [
                  {"option":"Answer 1",   "correct": false},
                  {"option":"Answer 2",   "correct":true},
                  {"option":"Answer 3",   "correct":false},
                  {"option":"Answer 4", "correct": false}
              ],
              "image": false,
              "source": false
          },
          {
              "q": "Question 2",
              "a": [
                  {"option":"Answer 1",   "correct": false},
                  {"option":"Answer 2",   "correct":true},
                  {"option":"Answer 3",   "correct":false},
                  {"option":"Answer 4", "correct": false}
              ],
              "image": false,
              "source": false
          }, //goes on again
  </code></pre>
  
  <p>And my JavaScript</p>
  
  <pre><code>function quizFun() {
      var questions = [];
      var answers = [];
      var quiz = "url.to/questions.json";
  
      $.getJSON(quiz, function(data) {
          lvl_1(data);
          function lvl_1(data) {
              var easy = data.easy_questions;
  
              function shuffle(array) {
                  var counter = array.length, temp, index;
                      // While there are elements in the array
                      while (counter--) {
                          // Pick a random index
                          index = (Math.random() * counter) | 0;
                          // And swap the last element with it
                          temp = array[counter];
                          array[counter] = array[index];
                          array[index] = temp;
                      }
  
                      return array;
              }
              var randoms = shuffle(easy.slice(0));
              randoms.length = 3;
  
              jQuery.each(randoms, function(i, val) {
                  var question = val.q,
                      sourse = val.source;
                      img = val.image;
                      answ = val.a;
                      option = null;
                      correct = null;
  
                  $.each(answ,function(option, correct) {
                      option = this.option;
                      correct = this.correct;
                      answers = '&lt;span data-true="'+correct+'"&gt;'+option+'&lt;/span&gt;';
  
                      return answers;
  
                  });
                  if(!img) {
                      html_strucutre = question + answers;
                  } else {
                      html_strucutre = question + '&lt;img src="'+img+'" width="300"&gt;' + answers;
                  }
  
                  $('body').append(html_strucutre+'&lt;br&gt;');
              });
          }
      });
  </code></pre>
  
  <p>I know this isn't the best possible, but I'm trying to sort this one out with small steps. </p>
  
  <p>First, I need to get 3 random questions 'easy_questions', with their corresponding answers (true or false). Once I'm going through 3 of those, I'll be jumping off to the next one and so on. </p>
  
  <p>I did manage to get the questions and even the answers, but whenever I'm trying to exit the <code>$.each(answ,function(option, correct) {..}</code>  it's only returning one answer per question and always the last one. </p>
  
  <p>What exactly is terribly wrong here?</p>