Home

Published

- 1 min read

square pattern printing in javascript

img of square pattern printing in javascript

The solution for this is noted below

square pattern printing in javascript

Solution

   //set a variable for the integer needed to make your desired sqaure.
const row = 5
// Run a for loop to iterate through it.
for (let i = 0; i < row; i++) {
	let result = ''
	// inner loop to iterate within
	for (let j = 0; j < row; j++) {
		result += 'X' // feel free to use any letter instead of X depending on your need.
	}
	console.log(result)
}

Try other methods by searching on the site. That is if this doesn’t work