Suppose I have the following Javascript code:
var i = 0;
var list = ['a','b','c'];
for (var key in list) {
// some other operations on list[key]
// in case they are successful
i = i + 1;
}
if (i == list.length) {
console.log('cycle complete');
}
The idea is that a certain function (in this case console.log
) fires after the cycle is complete.
What would be a more efficient way to achieve the same tasks?
Maybe functional programming?