Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Commit 1bd4677

Browse files
committed
Fix JS array-pair-sum tests
1 parent d8cced6 commit 1bd4677

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

solutions/javascript/array-pair-sum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = function arraypairsum (k, array) {
1010
var len = hash[diff];
1111

1212
while (len--) {
13-
pairs.push([number, diff]);
13+
pairs.push([diff, number]);
1414
}
1515

1616
hash[number] = (hash[number] + 1) || 1;

tests/javascript/array-pair-sum.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ describe('Array Pair Sum', function () {
77
});
88

99
it('should not output duplicate results', function () {
10-
expect(arrayPairSum(8, [3, 4, 5, 4, 4])).to.eql([[3, 5], [4, 4]]);
10+
expect(arrayPairSum(8, [3, 4, 5, 4, 4])).to.eql([[3, 5], [4, 4], [4, 4], [4, 4]]);
1111
});
1212

13-
it('should only allow distinct elements', function () {
14-
expect(arrayPairSum(4, [1, 1, 2, 3, 4])).to.eql([[1, 3]]);
15-
});
13+
it('should work not find any matches', function () {
14+
expect(arrayPairSum(10, [3, 5, 6, 8])).to.eql([]);
15+
})
1616
});

0 commit comments

Comments
 (0)