Skip to content
This repository was archived by the owner on Feb 20, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})