1const binaryArrayToNumber = arr => {
2 let len = arr.length
3 let pow = []
4 let decimal = []
5 for(let i = 0; i <= len - 1; i++){
6 pow.unshift(i)
7 }
8 arr.forEach((x,index) => {
9 decimal.push(x*2**pow[index])
10 })
11 let toDecimal = decimal.reduce((acc, curr) => acc + curr, 0)
12 return toDecimal
13};
14console.log(binaryArrayToNumber([1, 0, 1, 1]))