return default index when not found

This commit is contained in:
fatedeity
2019-08-11 16:20:26 +08:00
parent 1cee67393c
commit 80164c8a52
3 changed files with 10 additions and 5 deletions

View File

@ -6,3 +6,6 @@ test('findLastIndex is a Function', () => {
test('Finds last index for which the given function returns true', () => {
expect(findLastIndex([1, 2, 3, 4], n => n % 2 === 1)).toBe(2);
});
test('Return default index when not found', () => {
expect(findLastIndex([1, 2, 3, 4], n => n === 5)).toBe(-1);
});