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

Commit d00b122

Browse files
yeashinrKent C. Dodds
authored and
Kent C. Dodds
committed
feat(second): add second function (#242)
* feat(second): add second function * feat(second): resolve the issues
1 parent 38b6e73 commit d00b122

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ import validateEmail from './validateEmail'
9191
import removeElementByIndex from './removeElementByIndex'
9292
import clone from './clone'
9393
import arrMultiply from './array-multiplier'
94+
import second from './second'
9495

9596
export {
9697
reverseArrayInPlace,
@@ -186,4 +187,5 @@ export {
186187
removeElementByIndex,
187188
clone,
188189
arrMultiply,
190+
second,
189191
}

src/second.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default second
2+
/*
3+
*source :https://stackoverflow.com/questions/44531677
4+
* function return second element of the array.
5+
* @param {Number} array - any
6+
* return boolean value
7+
*/
8+
9+
function second(array) {
10+
return array[1]
11+
}

test/second.test.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import test from 'ava'
2+
import {second} from '../src'
3+
4+
test('Return second elements of the array', t => {
5+
const array = [1, 2, 3, -1]
6+
const expected = array[1]
7+
const actual = second(array)
8+
t.deepEqual(actual, expected)
9+
})

0 commit comments

Comments
 (0)