I'm pretty new to NodeJS and I am trying to solve the following problem related to callback functions.
var lib = require('someLibrary');
function main() {
for(var i = 0; i <10; i++) {
var num = someArray[i];
lib.validate(function(result) {
if(result.value === num) {
console.log('Found it');
}
}
}
}
main();
Now here since validate() takes a callback, my num is always out of sync. Any ideas on how to solve this problem?