Grains - Javascript - problem with the test answer? Other people also seem to be using a workaround to make answer match test
- Dominant language
- No language data
- Stars
- 3
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
I found that for the test
```
test('total', () => {
expect(grains.total()).toBe('18446744073709551615');
});
```
using big-integer.js gave me an answer of '18446744073709551616' no matter what I did. So I looked at other people's answers to figure out what I was doing wrong.
What I found was that other people were just subtracting 1 from the 'total' method in their answers using a variety of different fixes so I did the same. There was only one test involving the `total` method so all tests passed that way.
However, upon reflection, maybe the test should be fixed.
Here was my `total` method:
```
total() {
let tot = bigInt(0);
for (let i = 2; i < 65; i++) {
tot = tot + parseInt(this.square(i))
}
return bigInt(tot).minus(1).toString();
}
```
The `.minus(1)` in the second to last line was my "fix".
Or, if I really am supposed to get '18446744073709551615' what should I be doing instead?
My full answer is here: https://exercism.io/my/solutions/2261a8c46c844d43992a4ac2c7ba5e03
_Originally posted by @beansprout in https://github.com/exercism/r/issues/106#issuecomment-481869046_
(moved because I was in the wrong track. Oops!)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the JavaScript `total` test shown in the issue and inspect the referenced `total()` method and full solution. Compare the test expectation with the exercise's intended calculation and verify that the corrected behavior passes all relevant tests without a workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100