当前位置:网站首页>[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
边栏推荐
- varnish入门
- Kanban Quick Start Guide
- MySQL series - install MySQL 5.6.27 on Linux and solve common problems
- 2021-09-23
- Nécessité de précharger les cookies dans le sélénium
- Why can't V-IF and V-for be used together
- egg中的多进程模型--egg文档搬运工
- Three of three JS (webgl) is simple to draw lines / arcs according to points (based on linegeometry / line2 / linematerial, draw two arc segments based on the center of the circle)
- 学习笔记:Unity CustomSRP-12-HDR
- Solution of how to log in with mobile phone verification code in wireless network
猜你喜欢
When is it appropriate for automated testing? (bottom)
varnish入门
Modèle axé sur le domaine DDD (III) - gestion des transactions à l'aide de Saga
Three of three JS (webgl) simple sorting of rotation attribute function, and a simple case of rotating around the axis based on this
无线网怎么用手机验证码登录解决方案
selenium預先加載cookie的必要性
!!!!!!!!!!!!!!!!!!
Necessity of selenium preloading cookies
es6数组的使用
Branch and loop statements
随机推荐
看板快速启动指南
App Store年交易额100万美元只缴15%佣金,中小开发者心里很矛盾
node中的redis使用--ioredis
My old programmer's perception of the dangers and opportunities of the times?
狼叔来找翻译人员了--plato--持续翻译中.....
改进DevSecOps框架的 5 大关键技术
Anti crawler (0): are you still climbing naked with selenium? You're being watched! Crack webdriver anti crawler
如果我是pm之 演出电影vr购票展示
Redis的基本知识
MySQL series - install MySQL 5.6.27 on Linux and solve common problems
2021-11-01
点击添加按钮--出现一个框框(类似于添加学习经历-本科-研究生)
es6数组的使用
【openh264】cmake: msopenh264-static
Publish your own wheel - pypi packaging upload practice
Multiple mainstream SQL queries only take the latest one of the data
跨域CORS的情缘~
After NPM was upgraded, there was a lot of panic
Laravel routing job
If the route reports an error after deployment according to the framework project