当前位置:网站首页>[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
边栏推荐
- After NPM was upgraded, there was a lot of panic
- MFC implementation resources are implemented separately by DLL
- egg中的多进程模型--egg文档搬运工
- 使用 Kears 实现ResNet-34 CNN
- 低代码和无代码的注意事项
- 2021-10-08
- 即将毕业的大学生找技术开发工作的焦虑根源
- Kanban Quick Start Guide
- Modèle axé sur le domaine DDD (III) - gestion des transactions à l'aide de Saga
- Branch and loop statements
猜你喜欢

Laravel routing job

If I am PM's performance, movie VR ticket purchase display

Blender programmed terrain production

Open source rule engine - Ice: dedicated to solving flexible and complex hard coding problems

2021-10-08

(十一)vscode代码格式化配置

分支与循环语句

数字化转型失败,有哪些原因?

phphphphphphphp

Three 之 three.js (webgl)旋转属性函数的简单整理,以及基于此实现绕轴旋转的简单案例
随机推荐
Good test data management, in the end how to do?
Blender程序化地形制作
App Store年交易额100万美元只缴15%佣金,中小开发者心里很矛盾
SQL Server检索SQL和用户信息的需求
Asynchronous iterator & asynchronous generator & asynchronous context manager
工具在数字化转型中扮演了什么样的角色?
C#测试调用PaddleSharp模块识别图片文字
FileReader API file operation
Uniapp hot update with progress bar
Nécessité de précharger les cookies dans le sélénium
分支与循环语句
Necessity of selenium preloading cookies
Log introduction and building web application
2021-10-12
Three 之 three.js (webgl)模型的删除/场景的清空/内存的释放 的简单整理
CORS and proxy (づ  ̄ 3  ̄) in egg ~ the process of stepping on the pit and filling the pit ~ tot~
MFC implementation resources are implemented separately by DLL
selenium預先加載cookie的必要性
After NPM was upgraded, there was a lot of panic
Open source rule engine - Ice: dedicated to solving flexible and complex hard coding problems