Need writing a java script that will list prime numbers from 1 - 999
in a 10 Row table...I think I have the prime number logic part down but I cant figure out how to get JS to start a new column after it lists 10 numbers? I would obviously need a counter variable to count from 1 to 10 each time the loop is executed positive for a prime number then reset at 10 but I cannot figure out how. Any help would be appreciated

Sorry if this isn't the right section of the forum I didnt see anything for Java script

var rowCounter = 0;
var columnCounter = 0;
for(var i = 0, len = 999; i < len; i++) {
	if(some prime number logic returns true) {
		rowCounter++; // increment row counter
		if(rowCounter >= 10) { // if ten rows have been written
			rowCounter = 0; // reset row counter
			columnCounter++; // next column
		}
		
		/*
			output number to table.row[rowCounter].column[columnCounter]  assuming table, rows and columns already exist
		*/
	}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.