CodePudding user response:
var line=4;
Var arr=[];
for(var i=0; iIf (I==0)
{
Arr. Push (repeat (' * ', line * 2-1));
} else {
Arr. Push (repeat repeat (' ', I) + (' * '(line - I) * 2-1) + repeat ('', I))
Arr. Unshift (repeat repeat (' ', I) + (' * '(line - I) * 2-1) + repeat ('', I))
}
//arr. Push []
}
The console. The log (arr. Join (' \ n '))
The function repeat (STR, times) {
Return the new Array (+ 1) times. Join (STR);
}
CodePudding user response:
Why the console output is vertical, to the document. The write becomes a rowCodePudding user response:
Document. Write the input to the page, this is HTMLIf the document must be used. The write, then add the pre or XMP at before and after the tag
*
* * *
* * * * *
* * *
*
So you can according to the text format shows