This repository was archived by the owner on Feb 20, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ export default BitwiseAnd
2
+
3
+ /**
4
+ * Original Source: https://stackoverflow.com/a/35211814
5
+ *
6
+ * This method will revers the order of a the chars in a string.
7
+ *
8
+ * @param {Array } array - Array
9
+ * @returns {Number } - Bitwise And of all the operations
10
+ */
11
+ function BitwiseAnd ( array ) {
12
+ return array . reduce ( ( a , b ) => {
13
+ return a & b //eslint-disable-line no-bitwise
14
+ } )
15
+ }
16
+
17
+
Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ import temperatureConverter from './temperatureConverter'
78
78
import last from './last'
79
79
import descendingOrder from './descending-order'
80
80
import reduceCount from './reduceCount'
81
+ import BitwiseAnd from './BitwiseAnd'
81
82
82
83
export {
83
84
reverseArrayInPlace ,
@@ -160,4 +161,5 @@ export {
160
161
last ,
161
162
descendingOrder ,
162
163
reduceCount ,
164
+ BitwiseAnd ,
163
165
}
Original file line number Diff line number Diff line change
1
+ import test from 'ava'
2
+ import { BitwiseAnd } from '../src'
3
+
4
+ test ( 'Returns the Bitwise And of all the Array Elements' , t => {
5
+ const name1 = [ 1 , 3 , 5 ]
6
+ const actual = BitwiseAnd ( name1 )
7
+ const expected = 1
8
+ t . deepEqual ( actual , expected )
9
+ } )
10
+
11
+
You can’t perform that action at this time.
0 commit comments