Assets/js/logic.js
// Renders questions and choices to page: 
Renders questions and choices to page.
Renders questions and choices to page .
function render(questionIndex) {
    questionDiv.innerHTML = "";
    ulCreate.innerHTML = "";
    for (var i = 0; i < question.length; i++) {
        var userQuestion = question[questionIndex].title;
        var userChoices = question[questionIndex].choices;
        questionDiv.textContent = userQuestion;
    }
    userChoices.forEach(function (newItem) {
        var listItem = document.createElement("li");
        listItem.textContent = newItem;
        questionDiv.appendChild(ulCreate);
        ulCreate.appendChild(listItem);
        listItem.addEventListener("click", (compare));
    })
}
function render ( questionIndex ) { questionDiv . innerHTML = "" ; ulCreate . innerHTML = "" ; for ( var i = 0 ; i < question . length ; i ++ ) { var userQuestion = question [ questionIndex ] . title ; var userChoices = question [ questionIndex ] . choices ; questionDiv . textContent = userQuestion ; } userChoices . forEach ( function ( newItem ) { var listItem = document . createElement ( "li" ) ; listItem . textContent = newItem ; questionDiv . appendChild ( ulCreate ) ; ulCreate . appendChild ( listItem ) ; listItem . addEventListener ( "click" , ( compare ) ) ; } ) }
Renders questions and choices to page:
Renders questions and choices to page :
// Clears existing data  // For loops to loop through all info in array // Appends question title only // New for each for question choices