0

My code is currently as follows. I'm using the Parse.Js library.

while (i < workout) {

    return q.find({
        success: function (type) {
            if (type == 3) {
                typeCount++;
            }
        }
    });
    i++;
}

The problem is the 'return' seems to stop the rest of the function from working. Is there a way to do this without breaking the loop?

I tried removing the return all together but then the q.find code doesn't run.

4

2 に答える 2

2

No. return ends execution of the function, breaking all loops, if blocks, etc. You can store the value in a variable and return that at the end (once your loops are finished), but return stops the function.

于 2013-02-19T19:10:03.900 に答える
2

There isn't, instead of 'return' you could add the values to an array and then return that array.

于 2013-02-19T19:10:08.080 に答える