当前位置:网站首页>[triangle Yang Hui triangle printing odd even cycle JS for break cycle]
[triangle Yang Hui triangle printing odd even cycle JS for break cycle]
2022-04-23 05:26:00 【Courtesy.】
1. Print triangles

for ( let i=0; i<10; i++) {
for ( let n=0; n<i; n++ ){
document.write("*");
}
document.write("<br/>");
}
2. Yang hui triangle

// 4 3 2 1
for ( let i=0; i<5; i++) {
for ( let n=5-i; n>0; n-- ){
document.write("^");
}
// 1 3 5 7
for ( let m=i*2-1; m>0; m-- ){
document.write("*");
document.write("<br/>");
}
Use for Cycle through odd numbers / even numbers

for ( let i=1; i<=10; i++){
if(i % 2) continue; // When i%2 When it is an odd number, continue to execute , Print when even
console.log;
}
Here is when the third odd number appears , Just stop Exit loop

let count = 0; // Define a counter , The default is 0
for ( let i=1; i<=10; i++){
if (i%2){
if ( count++ = 3) break; // When the counter is equal to 3 When it's time to exit the loop
}
console.log(i);
}
版权声明
本文为[Courtesy.]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220544339172.html
边栏推荐
- Call the interface to get the time
- 青岛敏捷之旅,来了!
- 如果我是pm之 演出电影vr购票展示
- 即将毕业的大学生找技术开发工作的焦虑根源
- 2021-10-08
- Solve the problem of JS calculation accuracy
- CPT 104_ TTL 09
- 学习笔记:Unity CustomSRP-11-Post Processing---Bloom
- Multi process model in egg -- egg document Porter
- Source code analysis of how to use jump table in redis
猜你喜欢

CPT 104_TTL 09

Uniapp wechat sharing

selenium預先加載cookie的必要性

领域驱动模型DDD(三)——使用Saga管理事务

Uncle wolf is looking for a translator -- Plato -- ongoing translation

Project manager's thinking mode worth trying: project success equation

Requirements for SQL server to retrieve SQL and user information

npm升级后问题,慌得一批

4 个最常见的自动化测试挑战及应对措施

Getting started with varnish
随机推荐
Three of three JS (webgl) simple sorting of rotation attribute function, and a simple case of rotating around the axis based on this
学习笔记:Unity CustomSRP-11-Post Processing---Bloom
我这位老程序员对时代危险和机遇的一点感悟?
Anti crawler (0): are you still climbing naked with selenium? You're being watched! Crack webdriver anti crawler
看板快速启动指南
mariadb数据库的主从复制
CPT 104_ TTL 09
JS Array常见方法
JSP -- Introduction to JSP
Multi process model in egg -- egg document Porter
PIP free export with path (@ file: / / /) notes
Open source rule engine - Ice: dedicated to solving flexible and complex hard coding problems
Ehcache Memcache redis three caches
Data management of basic operation of mairadb database
String class understanding - final is immutable
TSlint注释忽略错误和RESTful理解
MFC实现资源单独Dll实现
Why can't V-IF and V-for be used together
WTL 自绘控件库 (CQsCheckComboxBox)
Kanban Quick Start Guide