关于使用js的循环语句打印一个金字塔的三种方案

//for循环方式

<html>

<head>

<title>金字塔三角形</title>

<script>

var ta = prompt("请输入金字塔的行数");

//浏览行数

for(var i=1;i<=ta;i++){

//打印空格

for(var j=1;j<=(ta-i);j++){

document.write("&nbsp");

}

//打印星星

for(var k=1;k<=(2*i-1);k++){

document.write("*");

}

document.write("<br>");

}

</script>

</head>

<body>

</body>

</html>

相关推荐
KaMeidebaby5 小时前
卡梅德生物技术快报|PD1 单克隆抗体定制配套 N 糖全谱质控开发
前端·人工智能·算法·数据挖掘·数据分析
nuIl6 小时前
实现一个 Coding Agent(3):工具调用
前端·agent·cursor
nuIl6 小时前
实现一个 Coding Agent(4):ReAct 循环
前端·agent·cursor
nuIl6 小时前
实现一个 Coding Agent(1):一次 LLM 调用
前端·agent·cursor
nuIl6 小时前
实现一个 Coding Agent(2):让 LLM 流式响应
前端·agent·cursor
copyer_xyf6 小时前
Python 异常处理
前端·后端·python
sugar__salt6 小时前
从栈队列数据结构到JS原型面向对象全解
前端·javascript·数据结构
倔强的石头1066 小时前
【Linux指南】Linux快捷键与系统实用技巧
linux·运维·服务器
番茄地瓜6 小时前
Linux 配置静态 IP 步骤
linux·运维·服务器
liulilittle6 小时前
论 Linux 内核态全局稳态带宽的卡尔曼估计与工程实现
linux·服务器·网络·c++·计算机网络·tcp·通信