JavaScript - 警告数组的所有值

时间:2017-01-14 22:20:38

标签: javascript

我做了这个循环:

TestAppWithJack[71791] <Error> [Firebase/Core][I-COR000012] Could not locate configuration file: 'GoogleService-Info.plist'.
2017-01-14 17:06:19.456 TestAppWithJack[71791:2160021] *** Terminating app due to uncaught exception 'com.firebase.core', reason: '[FIRApp configure] could not find a valid GoogleService-Info.plist in your project.

我想知道,如何将var intt =number; var divider=[intt]; var i; var count=0; var b; var temp=0; var temp2=0; for(i=1; i<=intt; i++){ if(number%i==0){ divider[count]=i; b=count++; } } 的所有值都放在divider中?

2 个答案:

答案 0 :(得分:2)

如果您愿意,可以这样做:

alert(JSON.stringify(divider));

或者,您可以将join所有值放入一个字符串中,如下所示:

alert(divider.join(", "));

然后在你的代码之后添加它:

var intt =number;
var divider=[intt];
var i;
var count=0;
var b;
var temp=0;
var temp2=0;

for(i=1; i<=intt; i++){

    if(number%i==0){
        divider[count]=i;
        b=count++;

    }       
}

alert(divider.join(", "));

答案 1 :(得分:0)

如果我理解你的问题:

    var intt =number;
    var divider=[intt];
    var i;
    var count=0;
    var b;
    var temp=0;
    var temp2=0;

    var strBldr = "";

    for(i=1; i<=intt; i++){

        if(number%i==0){
            strBldr = "".join(i+", ");
            divider[count]=i;
            b=count++;

        }       
    }

    strBldr = strBldr.slice(0, -2);
    alert(strBldr);