ga-wdi-exercises / project1

[project] GA- Project 1
3 stars 75 forks source link

Iterate through array in an object #226

Closed yinkaagiri closed 8 years ago

yinkaagiri commented 8 years ago

How do I iterate through each question and save the question in a variable or show it in console? Here is what I tried, it doesn't throw error in console but it's not doing what I want either.


  scienceQue: function(){
    for (var i = 0; i <science.question.length; i++)
    var ask = science.question[i];
    console.log(ask);

  },
science: [
  { question: "What size is",
    choices: [10,44,15],
    correctIndex: 1
  },

  { question: "???",
    choices: [0,1,2],
    correctIndex: 2
  }

]
}```