I need a pure or jquery script that runs a row and column structure. Example, if the user type 7 I have to print the following structure:
x
xx
xxx
xxxx
xxxxx
xxxxxx
xxxxxxx
I tried to use for but only runs the line.
I need a pure or jquery script that runs a row and column structure. Example, if the user type 7 I have to print the following structure:
x
xx
xxx
xxxx
xxxxx
xxxxxx
xxxxxxx
I tried to use for but only runs the line.
There are several ways to do this. When you say print, I will use the console to show the result.
var numero = 7; // Número inserido pelo usuário.
var caracter = 'x'; // Caracter que deseja imprimir.
var resultado = ''; // Variável para armazenar o resultado e imprimir.
for(i = 0; i < numero; i++){
resultado = resultado + caracter;
console.log(resultado);
}
This will result in the console:
x
xx
xxx
xxxx
xxxxx
xxxxxx
xxxxxxx