【发布时间】:2017-04-24 19:13:21
【问题描述】:
如何将循环的每个变量放入一个数组中并调用其他变量中的所有变量。
我对数组很陌生。我不知道如何解决这个问题。
假设我有一个Array[]
而数组中的变量是i,所以i1, i2, i3 ....... in
n 是循环运行的次数。
所以
for (i=1; i<=n, i++) {
//I need an array called here.
//there will be some code play here
//There will be some value returned after the code it could be text or no.
}
然后我想将数组的所有值分配给一个以逗号分隔的变量
var k = array{} i.e k = "i1,i2,i3,......in"
我尝试在 Google 上查找,但找不到任何解决方案。
这个例子是我实际想要达到的参考。
【问题讨论】:
-
请格式化您的问题。很难阅读和理解
-
你不要调用数组
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
-
@halfer 你是如何以如此简洁的方式编辑问题的?
-
我使用了Markdown,这是一种很好的基于文本的方式来指定富文本格式。
标签: javascript arrays loops for-loop