E
E
Evgenij_nechujveter2017-04-04 22:59:16
JavaScript
Evgenij_nechujveter, 2017-04-04 22:59:16

How does this array work?

1802390423b84458966502c88a7d8b4c.png
People help to deal with the array. I understand what the result will be in the end, but I do not understand how it works.
For example, in line 14: array[array.length - i - 1] - Why do we get 8 here? What does i equal here? -1 - are we discarding the last cell?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Shilov, 2017-04-04
@Evgenij_nechujveter

It is obvious that in [14] line at the zero place of the array array we put an element from the zero line and the 7th column, and this element is equal to 8. means that there are 8 elements in the array, but because the array starts from a zero element, then according to the rules, the number of the last cell is 1 less, i.e. 7, so . is explained by the fact that we gradually go through all the cells in order, starting with the last one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question