Slider Pagination Quiz

Quiz 1 3 questions

Prerequisites for the quiz

  1. The whole Slider Pagination chapter

Are you ready?

3 questions to solve

Instructions
  1. This quiz goes to full-screen once you press the Start button.
  2. At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
Which one of the following is more efficient that the other?

Snippet 1:

var paginationHTML = "";
for (var i = 0; i < slidesLength; i++) {
   paginationHTML += '<button class="slider_pagination_btn"></button>';
}
paginationElement.innerHTML = paginationHTML;

Snippet 2:

var paginationHTML = [];
for (var i = 0; i < slidesLength; i++) {
   paginationHTML.push('<button class="slider_pagination_btn"></button>');
}
paginationElement.innerHTML = paginationHTML.join("");
Snippet 1 uses string concatenation to form the string to be put into pagination.innerHTML, which is relatively less efficient than joining all the individual strings once using the join() array method. See more at Slider Pagination.
Which of the following two mechanisms do we use to make each pagination button interactive?
We go with choice 2, as is detailed in Slider Pagination.
How does our script know which slide index does a given pagination button correspond to?
Each pagination button has a data-index attribute on it that holds the index of the slide corresponding to it. See more at Slider Pagination.