Top "For-loop" questions

A for loop is a control structure used by many programming languages to iterate over a range.

Postgres FOR LOOP

I am trying to get 25 random samples of 15,000 IDs from a table. Instead of manually pressing run every time, I'm …

postgresql stored-procedures for-loop random plpgsql
Breaking out of a nested loop

If I have a for loop which is nested within another, how can I efficiently come out of both loops (…

c# for-loop nested-loops
How to stop a JavaScript for loop?

I'm using this JavaScript to iterate through an array and find a matching array element: var remSize = [], szString, remData, remIndex, …

javascript for-loop
What does the colon (:) operator do?

Apparently a colon is used in multiple ways in Java. Would anyone mind explaining what it does? For instance here: …

java for-loop foreach operators colon
Skipping every other element after the first

I have the general idea of how to do this in Java, but I am learning Python and not sure …

python for-loop elements
push() a two-dimensional array

I'm trying to push to a two-dimensional array without it messing up, currently My array is: var myArray = [ [1,1,1,1,1], [1,1,1,1,1], [1,1,1,1,1] ] And my …

javascript arrays for-loop multidimensional-array push
Why does python use 'else' after for and while loops?

I understand how this construct works: for i in range(10): print(i) if i == 9: print("Too big - I'm giving …

python if-statement for-loop for-else
How to concat string + i?

for i=1:N f(i) = 'f'+i; end gives an error in MatLab. What's the correct syntax to initialize an …

string matlab loops for-loop octave
Sum values from an Array in JavaScript

I have defined a JavaScript variables called myData which is a new Array like this: var myData = new Array(['2013…

javascript arrays for-loop sum
Is it a bad practice to use break in a for loop?

Is it a bad practice to use break statement inside a for loop? Say, I am searching for an value …

for-loop break