js打印三角形


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>打印三角形title>
head>

<body style="text-align:center;">
<script  type="text/javascript">
var k=prompt("请输入打印的行数:","");//prompt()--param2:默认值
for(var i=1;i<=k;i++){//控制行数
    for(var j=0;j//每行打印i个*
        document.write("*  ");
     }
    document.write("
"
); } script> body> html>

你可能感兴趣的:(js)