我有这个运行良好的代码
var name_1 = request.body.agentname_1;
var name_2 = request.body.agentname_2;
var name_3 = request.body.agentname_3;
...
var name_999 = request.body.agentname_999;
我想通过使用“For”循环来减少代码行。我试过这个,但我得到了错误,有什么帮助吗?谢谢你
for (i = 1; i <= 999; i++) {
global['name_'+i] = request.body.global['agentname_'+i]
}