trekhleb/javascript-algorithms

The "i" of the for loop can be initialized with the value 2

phcmiguez opened this issue · 10 comments

The "i" of the for loop can be initialized with the value 2

Hey! I am new to open source, I want to take up the issue can you please guide me a bit. Can you please assign me to this task.

can you specify in which for loop the value of 'i' should be 2 ?

for (var i = 2; i < 10; i++) {
console.log(i);
}

This for loop will start with i equal to 2, and will continue until i is less than 10. On each iteration of the loop, the value of i will be logged to the console.

@phcmiguez hey i want to contribute to this project.

Dumte commented

Can I declare my variable before the for loop statement?

yes you can

Hey yes you can declare it as an I or as any other name but as we have studied was always I and one thing more you can give any value to it ,

Hey, is this issue still opened

You can initalize i value with 2. If you initialize I with 2 then the loop will start with the i value of 2.

If you use for loop like this ,

for (var i = 2; i < 50; i++) { console.log[i] }

you get all the number from 2 to 49.

can you specify in which for loop the value of 'i' should be 2 ?