Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

Commit

Permalink
feat(second): add second function (#242)
Browse files Browse the repository at this point in the history
* feat(second): add second function

* feat(second): resolve the issues
  • Loading branch information
yeashinr authored and Kent C. Dodds committed Feb 12, 2019
1 parent 38b6e73 commit d00b122
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ import validateEmail from './validateEmail'
import removeElementByIndex from './removeElementByIndex'
import clone from './clone'
import arrMultiply from './array-multiplier'
import second from './second'

export {
reverseArrayInPlace,
Expand Down Expand Up @@ -186,4 +187,5 @@ export {
removeElementByIndex,
clone,
arrMultiply,
second,
}
11 changes: 11 additions & 0 deletions src/second.js
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]
}
9 changes: 9 additions & 0 deletions test/second.test.js
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)
})

0 comments on commit d00b122

Please sign in to comment.