This repository has been archived by the owner on Feb 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(second): add second function (#242)
* feat(second): add second function * feat(second): resolve the issues
- Loading branch information
Showing
3 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default second | ||
/* | ||
*source :https://stackoverflow.com/questions/44531677 | ||
* function return second element of the array. | ||
* @param {Number} array - any | ||
* return boolean value | ||
*/ | ||
|
||
function second(array) { | ||
return array[1] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import test from 'ava' | ||
import {second} from '../src' | ||
|
||
test('Return second elements of the array', t => { | ||
const array = [1, 2, 3, -1] | ||
const expected = array[1] | ||
const actual = second(array) | ||
t.deepEqual(actual, expected) | ||
}) |