jadjoubran / codetogo.io

🚀 JavaScript code to go - Find updated snippets for common JavaScript use cases
https://codetogo.io
MIT License
233 stars 30 forks source link

Use Case Suggestion: How to create the For loop #25

Closed politologu closed 6 years ago

politologu commented 6 years ago
// Initialize a for statement with 5 iterations
for (let i = 0; i < 4; i++) {
    // Print each iteration to the console
    console.log(i);
}
// Output
0
1
2
3
itamark commented 6 years ago

This already exists: https://codetogo.io/how-to-loop-through-array-in-javascript/

jadjoubran commented 6 years ago

Indeed @itamark I've rarely used this for loop as I mostly use .forEach or for .. of I was thinking though it may be useful to use this for loop when you're counting, or when you're counting and skipping some numbers, for example from 1 to 10 skipping 2 numbers so when I add this, I'll reformulate it in order to avoid collision with how to loop through array in javascript

itamark commented 6 years ago

@jadjoubran in general - you should open-source this. Suggesting new entries is not what I had in mind when I clicked "Contribute". You can still be editor and merge things or not, but it'd be great if people could contribute actual new examples.

politologu commented 6 years ago

@itamark is not same, my suggestion is totally for beginner :)

politologu commented 6 years ago

Hi my friends, I am back here.

Thanks Qazim Rama