Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null return in front end can be sorted by having an if loop in server end checking if null return different definition. #56

Open
sohilpandya opened this issue Oct 3, 2015 · 5 comments

Comments

@sohilpandya
Copy link
Contributor

No description provided.

@tormod17
Copy link
Member

tormod17 commented Oct 3, 2015

Have you fixed it? I'll give it a go later

@tormod17 tormod17 closed this as completed Oct 3, 2015
@tormod17 tormod17 reopened this Oct 3, 2015
@tormod17
Copy link
Member

tormod17 commented Oct 3, 2015

Didn't mean to close that

@sohilpandya
Copy link
Contributor Author

Not given it a go yet let me know if you manage to get it done. I'll try to have a go tomorrow.

@sohilpandya
Copy link
Contributor Author

@tormod17 had any luck with solving this? I am stuck a bit.

in handler.js I am trying to do the following

    ac.import(function(err, words) {
      ac.findWord(userInput, function(err, found) {
        response.write(JSON.stringify(found));
        var ran = Math.random();
        if (found.length > 10) {
          ran = Math.floor(ran * 10);
        } else {
          ran = Math.floor(ran * found.length);
        }

        ac.define(found[ran], function(err, definition) {
 ------------------------- changes below -----------------------
          if(definition == null){
            console.log("---if loop for null definition");
            // change number in ran.
          }
          else{
            // continue with def.

          console.log("---- def in handler",definition);
          response.write('£' + definition);
          response.end('£' + ran.toString());
        } 
 ------------------------- changes above -----------------------
        });

      });
    });

Creating that if loop for null definitions. but having a tough time trying to solve how if the definition is null we can get it to run the math.random for the var run again.

@tormod17
Copy link
Member

tormod17 commented Oct 4, 2015

Yeah I tried earlier today and ran a ground and suddenly realised I didn't
understand how the callback() function works on the API request. I was
goig to have a go at a function that reset if difinfition is zero and then
calls the rest of the functions again. Haven't tried yet.

On 4 October 2015 at 12:03, Sohil Pandya [email protected] wrote:

@tormod17 https://github.com/tormod17 had any luck with solving this? I
am stuck a bit.

in handler.js I am trying to do the following

ac.import(function(err, words) {
  ac.findWord(userInput, function(err, found) {
    response.write(JSON.stringify(found));
    var ran = Math.random();
    if (found.length > 10) {
      ran = Math.floor(ran * 10);
    } else {
      ran = Math.floor(ran * found.length);
    }

    ac.define(found[ran], function(err, definition) {

------------------------- changes below -----------------------
if(definition == null){
console.log("---if loop for null definition");
// change number in ran.
}
else{
// continue with def.

      console.log("---- def in handler",definition);
      response.write('£' + definition);
      response.end('£' + ran.toString());
    }

------------------------- changes above -----------------------
});

  });
});

Creating that if loop for null definitions. but having a tough time trying
to solve how if the definition is null we can get it to run the math.random
for the var run again.


Reply to this email directly or view it on GitHub
#56 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants