Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (var i=0;i < answers.length;i++)
- {
- console.log(i)
- var question_ans = eval('(' + answers[i]+ ')');
- var question_to_find = question_ans.question.toString()
- var ans = question_ans.ans.toString()
- console.log(ans)
- quiz.where("question",question_to_find).exec(function(err,results)
- {
- console.log(results)
- if (ans == "t")
- {
- user_type = results.t
- }
- else if (ans == "f")
- {
- user_type=results.f
- }
- })
- }
- 0
- t
- 1
- f
- [ { question: 'i was here',
- _id: 5301da79e8e45c8e1e7027b0,
- __v: 0,
- f: [ 'E', 'N', 'F' ],
- t: [ 'E', 'N', 'F' ] } ]
- [ { question: 'WHo r u ',
- _id: 5301c6db22618cbc1602afc3,
- __v: 0,
- f: [ 'E', 'N', 'F' ],
- t: [ 'E', 'N', 'F' ] } ]
- function asyncLoop( i, callback ) {
- if( i < answers.length ) {
- console.log(i)
- var question_ans = eval('(' + answers[i]+ ')');
- var question_to_find = question_ans.question.toString()
- var ans = question_ans.ans.toString()
- console.log(ans)
- quiz.where("question",question_to_find).exec(function(err,results) {
- console.log(ans, results)
- if (ans == "t") {
- user_type = results.t
- } else if (ans == "f") {
- user_type=results.f
- }
- asyncLoop( i+1, callback );
- })
- } else {
- callback();
- }
- }
- asyncLoop( 0, function() {
- // put the code that should happen after the loop here
- });
- for (var i=0;i < answers.length;i++) {
- console.log(i)
- var question_ans = eval('(' + answers[i]+ ')');
- var question_to_find = question_ans.question.toString()
- var ans = question_ans.ans.toString()
- console.log(ans)
- (function( ans ) {
- quiz.where("question",question_to_find).exec(function(err,results) {
- console.log(ans, results)
- if (ans == "t") {
- user_type = results.t
- } else if (ans == "f") {
- user_type=results.f
- }
- })
- }(ans));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement