I need to write a script that outputs XHTML to display the following patterns:
a)
*
**
b)
s *********
s s***
s s s***
s s s s***
s s s s s**
s s s s s s**
s s s s s s s*
s s s s s s s s**
s s s s s s s s s
s= blank spaces
the 2nd pattern starts with 10 asterisks, then 1 blank space and 9 asterisks, 2 blank spaces and 8 asterisks, 3 blank spaces and 7 asterisks…9 blank spaces and 1 asterisks
All asterisks (*) should be printed by a single statement of the form document.write( “
I was able to do the first pattern but I’m stuck with the second one. Anyone can help? Thanks
This is my script for the first pattern:
<!–
nextRow:
for ( var row = 1; row <= 10; ++row) {
document.writeln( “<br />” );
for ( var column = 10; column <= 10; –column) {
if ( column < row )
continue nextRow;
document.write( “* ” );
}
}
//–>