Problems with arrays

Dear all,
Good afternoon,
I was trying to solve a challenge about arrays, and
sadly it is getting me too much time to solve it.
I should decide if i use a For Loop or a While Loop to iterate through the values in the temperatures array from the first item 100 to the last item 10. Besides inside the loop i should log the current value to the console.

var temperatures = [ 100, 90, 99, 80,70, 65, 30,10];
So far i was doing this 
for ( var i = 100;  i <= temperatures.length;  i -=1){

My biggest problem is related to the counter variable i -= 1,
as i see many different numbers i don´t know the amount exact which
decreases the value.
If somebody please can help me providing information or advises i will thank you so much ,
thank you all for your kind attention,
Best regards,

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


It decreases by 1.
i -= 1 is the same thing as i = i - 1.

1 Like