JavaScript for-loop问题 [英] JavaScript for-loop question
本文介绍了JavaScript for-loop问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
for循环有可能重复3次吗?例如,对于(i = 0;i≤5; i ++)
创建:1,2,3,4,5。
我想创建一个循环,这样做:1,1,1,2,2,2,3,3,3,4,4,4,5,5,5 $ /
是否可能?
解决方案
for(i = 1; i <= 5; i ++)
(j = 1; j <= 3; j ++)
print i;
Is it possible for a for-loop to repeat a number 3 times? For instance,
for (i=0;i<=5;i++)
creates this: 1,2,3,4,5. I want to create a loop that does this: 1,1,1,2,2,2,3,3,3,4,4,4,5,5,5
Is that possible?
解决方案
for (i=1;i<=5;i++)
for(j = 1;j<=3;j++)
print i;
这篇关于JavaScript for-loop问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文