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

0 is not a number. #1

Open
mruhlin opened this issue Jul 13, 2017 · 0 comments
Open

0 is not a number. #1

mruhlin opened this issue Jul 13, 2017 · 0 comments

Comments

@mruhlin
Copy link

mruhlin commented Jul 13, 2017

If a row that I'm sorting on is 0, sorting will fail and return an error that says a number is expected.

Example:

const students = [
   {
      id: 'alice',
      mathGrade: 100,
      englishGrade: 75
   },
   {
      id: 'bob',
      mathGrade: 100,
      englishGrade: 0
   }
];

const sortOptions = {
   includeScore: true,
   mathGrade: { weight: 0.7 }},
   englishGrade: {weight: 0.3 }}
};

weightSum(students, sortOptions);

This should sort the students with Alice followed by Bob, but instead it throws an exception.
Weighted sum error: wrong data type for englishGrade. Number is expected

If I change bob's englishGrade to 1, it sorts properly.

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