I am trying to loop through this array
var questions = [
{
ask: 'is Javascript the best language?',
correct: 0,
answer : [
{text: 'yes'},
{text: 'No'}
]
},
{
ask: 'is Javascript the most popular language?',
correct: 1,
answer : [
{text: 'yes'},
{text: 'No'}
]
},
]
and the point is I want to get every question with this loop and get these questions in console log
var currentQuestion = questions.length;
for( var i = 0; i < currentQuestion; i++){
console.log(questions[i]);
}
but console.log says: Uncaught TypeError: Cannot read property 'length' of undefined