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

submittedUser is undefined every once in a while #188

Open
tjeerdytsma opened this issue Oct 27, 2017 · 0 comments
Open

submittedUser is undefined every once in a while #188

tjeerdytsma opened this issue Oct 27, 2017 · 0 comments

Comments

@tjeerdytsma
Copy link

tjeerdytsma commented Oct 27, 2017

I found that every once in a while the program crashes on a undefined submittedUser in submittedUsers.

I used the following solution

function checkUsersValid(goodUsers) {
  return function allUsersValid(submittedUsers) {
    const result = submittedUsers.every(function (submittedUser) {
      const result = goodUsers.some(function(goodUser) {
        return submittedUser.id === goodUser.id;
      });
      return result;
    });
    return result;
  };
}

module.exports = checkUsersValid

which resulted in this error

/Users/tjeerd/Development/nodeschool/program.js:11
        return submittedUser.id === goodUser.id;
                            ^

TypeError: Cannot read property 'id' of undefined
    at /Users/tjeerd/Development/nodeschool/program.js:11:29
    at Array.some (<anonymous>)
    at /Users/tjeerd/Development/nodeschool/program.js:8:32
    at Array.every (<anonymous>)
    at allUsersValid (/Users/tjeerd/Development/nodeschool/program.js:6:35)
    at /usr/local/lib/node_modules/functional-javascript-workshop/exercises/basic_every_some/exercise.js:35:5
    at Array.forEach (<anonymous>)
    at /usr/local/lib/node_modules/functional-javascript-workshop/exercises/basic_every_some/exercise.js:34:9
    at obtainResult (/usr/local/lib/node_modules/functional-javascript-workshop/exercises/runner.js:100:21)
    at Exercise.<anonymous> (/usr/local/lib/node_modules/functional-javascript-workshop/exercises/runner.js:66:27)

Using node version v8.6.0 and functional-javascript-workshop@1.0.6

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

1 participant