trekhleb / javascript-algorithms

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
MIT License
185.07k stars 29.85k forks source link

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

Open ghost opened 1 year ago

ghost commented 1 year ago

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

BamaCharanChhandogi commented 1 year ago

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.

ShivamPandey00 commented 1 year ago

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

Skilly55 commented 1 year ago

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.

BamaCharanChhandogi commented 1 year ago

@phcmiguez hey i want to contribute to this project.

Dumte commented 1 year ago

Can I declare my variable before the for loop statement?

PrakarshSingh5 commented 1 year ago

yes you can

Ahamdzia commented 1 year ago

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 ,

utkarsh-shrivastav77 commented 1 year ago

Hey, is this issue still opened

pasan2002 commented 3 months ago

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.

miladhatami1393 commented 1 month ago

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